class LxChess::Notation
- LxChess::Notation
- Reference
- Object
Overview
Parses Standard Algebraic Notation
ex: Pbxc8=Q
pawn on the b file takes c8 and promotes to Queen
Defined in:
lx_chess/notation.crConstant 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
- .new(notation : String)
- .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)
Instance Method Summary
- #castles?
- #castles_k : Bool
- #castles_k=(castles_k : Bool)
- #castles_k? : Bool
- #castles_q : Bool
- #castles_q=(castles_q : Bool)
- #castles_q? : Bool
- #check : Bool
- #check=(check : Bool)
- #check? : Bool
- #checkmate : Bool
- #checkmate=(checkmate : Bool)
- #checkmate? : Bool
- #en_passant : Bool
- #en_passant=(en_passant : Bool)
- #en_passant? : Bool
- #fen_symbol(turn)
- #from : String | Nil
- #from=(from : String | Nil)
- #origin : String | Nil
- #origin=(origin : String | Nil)
- #piece_abbr
- #piece_id(turn = "w")
- #promotion : Char | Nil
- #promotion=(promotion : Char | Nil)
- #square : String | Nil
- #square=(square : String | Nil)
- #symbol
- #takes : Bool
- #takes=(takes : Bool)
- #takes? : Bool
- #to : String | Nil
- #to=(to : String | Nil)
- #to_h
-
#to_s
Returns a nicely readable and concise string representation of this object, typically intended for users.
- #validate
Constructor Detail
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)
#
Instance Method Detail
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
.