LxChess::Notation
Inherits Reference < Object
Parses Standard Algebraic Notation
ex: Pbxc8=Q pawn on the b file takes c8 and promotes to Queen
Constants
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)
Sourcenew(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)
SourceInstance methods
castles?
Sourcecastles_k
Sourcecastles_k=(castles_k : Bool)
Sourcecastles_k?
Sourcecastles_q
Sourcecastles_q=(castles_q : Bool)
Sourcecastles_q?
Sourcecheck
Sourcecheck=(check : Bool)
Sourcecheck?
Sourcecheckmate
Sourcecheckmate=(checkmate : Bool)
Sourcecheckmate?
Sourceen_passant
Sourceen_passant=(en_passant : Bool)
Sourceen_passant?
Sourcefen_symbol(turn)
Sourcefrom
Sourcefrom=(from : String | Nil)
Sourceorigin
Sourceorigin=(origin : String | Nil)
Sourcepiece_abbr
Sourcepiece_id(turn = "w")
Sourcepromotion
Sourcepromotion=(promotion : Char | Nil)
Sourcesquare
Sourcesquare=(square : String | Nil)
Sourcesymbol
Sourcetakes
Sourcetakes=(takes : Bool)
Sourcetakes?
Sourceto
Sourceto=(to : String | Nil)
Sourceto_h
Sourceto_s
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.
validate
Source