class LxChess::Notation

Overview

Parses Standard Algebraic Notation ex: Pbxc8=Q pawn on the b file takes c8 and promotes to Queen

Defined in:

lx_chess/notation.cr

Constant Summary

NOTATION_REGEX = /\ \A\s* (?<castle_k> ^[Oo0]-[Oo0] )?\s* (?<castle_q> ^[Oo0]-[Oo0]-[Oo0] )?\s* (?<piece_abbr> ^[RNBQKP](?!\d$) )?\s* (?<origin> (?:[a-wyz]|\d+|[a-z]\d+)(?=\s*x?\s*[a-z]\d+) )?\s* (?<takes> x )?\s* (?<dest> [a-z]\d+ )?\s* (?<promo> \=\s*[RNBQrnbq] )?\s* (?<check> \+ )?\s* (?<checkmate> \# )?\s* (?<en_passent> e\.?p\.? )?\s* \z /x

Constructors

Instance Method Summary

Constructor Detail

def self.new(notation : String) #

[View source]
def self.new(square : Nil | String = nil, castles_k : Bool = false, castles_q : Bool = false, en_passant : Bool = false, check : Bool = false, checkmate : Bool = false, takes : Bool = false, piece_abbr : Char | Nil = nil, origin : Nil | String = nil, promotion : Char | Nil = nil, from : Nil | String = nil, to : Nil | String = nil) #

[View source]

Instance Method Detail

def castles? #

[View source]
def castles_k : Bool #

[View source]
def castles_k=(castles_k : Bool) #

[View source]
def castles_k? : Bool #

[View source]
def castles_q : Bool #

[View source]
def castles_q=(castles_q : Bool) #

[View source]
def castles_q? : Bool #

[View source]
def check : Bool #

[View source]
def check=(check : Bool) #

[View source]
def check? : Bool #

[View source]
def checkmate : Bool #

[View source]
def checkmate=(checkmate : Bool) #

[View source]
def checkmate? : Bool #

[View source]
def en_passant : Bool #

[View source]
def en_passant=(en_passant : Bool) #

[View source]
def en_passant? : Bool #

[View source]
def fen_symbol(turn) #

[View source]
def from : String | Nil #

[View source]
def from=(from : String | Nil) #

[View source]
def origin : String | Nil #

[View source]
def origin=(origin : String | Nil) #

[View source]
def piece_abbr #

[View source]
def piece_id(turn = "w") #

[View source]
def promotion : Char | Nil #

[View source]
def promotion=(promotion : Char | Nil) #

[View source]
def square : String | Nil #

[View source]
def square=(square : String | Nil) #

[View source]
def symbol #

[View source]
def takes : Bool #

[View source]
def takes=(takes : Bool) #

[View source]
def takes? : Bool #

[View source]
def to : String | Nil #

[View source]
def to=(to : String | Nil) #

[View source]
def to_h #

[View source]
def to_s #
Description copied from class Object

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.


[View source]
def validate #

[View source]