Module: PGN::PositionFields
Overview
Instance Method Summary collapse
-
#board_string ⇒ String
The FEN/EPD board-string portion.
- #board_string=(board_fen) ⇒ Object
- #castling=(val) ⇒ Object
- #en_passant=(val) ⇒ Object
Instance Method Details
#board_string ⇒ String
Returns the FEN/EPD board-string portion.
26 27 28 |
# File 'lib/pgn/fen.rb', line 26 def board_string board.fen_board_string end |
#board_string=(board_fen) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/pgn/fen.rb', line 15 def board_string=(board_fen) squares = board_fen.gsub(/\d/) { |match| '_' * match.to_i } .split('/') .map(&:chars) .map { |row| row.map { |e| e == '_' ? nil : e } } .reverse .transpose self.board = PGN::Board.new(squares) end |
#castling=(val) ⇒ Object
6 7 8 |
# File 'lib/pgn/fen.rb', line 6 def castling=(val) @castling = val.nil? || val.empty? ? '-' : val end |
#en_passant=(val) ⇒ Object
10 11 12 |
# File 'lib/pgn/fen.rb', line 10 def en_passant=(val) @en_passant = val.nil? ? '-' : val end |