class

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)
Source
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)
Source

Instance methods

castles?
Source
castles_k
Source
castles_k=(castles_k : Bool)
Source
castles_k?
Source
castles_q
Source
castles_q=(castles_q : Bool)
Source
castles_q?
Source
check
Source
check=(check : Bool)
Source
check?
Source
checkmate
Source
checkmate=(checkmate : Bool)
Source
checkmate?
Source
en_passant
Source
en_passant=(en_passant : Bool)
Source
en_passant?
Source
fen_symbol(turn)
Source
from
Source
from=(from : String | Nil)
Source
origin
Source
origin=(origin : String | Nil)
Source
piece_abbr
Source
piece_id(turn = "w")
Source
promotion
Source
promotion=(promotion : Char | Nil)
Source
square
Source
square=(square : String | Nil)
Source
symbol
Source
takes
Source
takes=(takes : Bool)
Source
takes?
Source
to=(to : String | Nil)
Source
to_h
Source
to_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.

Source
validate
Source

Nested types