Class: Bchess::PGN::MoveInfoParser
- Inherits:
-
Object
- Object
- Bchess::PGN::MoveInfoParser
- Defined in:
- lib/pgn/move_info_parser.rb
Constant Summary collapse
- CHECK =
'+'.freeze
- TAKE =
'x'.freeze
- TAKE_2 =
':'.freeze
- MATE =
'#'.freeze
- PROMOTION =
'='.freeze
Instance Attribute Summary collapse
-
#castle ⇒ Object
Returns the value of attribute castle.
-
#info ⇒ Object
Returns the value of attribute info.
-
#move ⇒ Object
Returns the value of attribute move.
-
#move_string ⇒ Object
Returns the value of attribute move_string.
Instance Method Summary collapse
-
#initialize(move, castle) ⇒ MoveInfoParser
constructor
A new instance of MoveInfoParser.
- #parse_move_string ⇒ Object
Constructor Details
#initialize(move, castle) ⇒ MoveInfoParser
Returns a new instance of MoveInfoParser.
12 13 14 15 |
# File 'lib/pgn/move_info_parser.rb', line 12 def initialize(move, castle) @move = move @castle = castle end |
Instance Attribute Details
#castle ⇒ Object
Returns the value of attribute castle.
4 5 6 |
# File 'lib/pgn/move_info_parser.rb', line 4 def castle @castle end |
#info ⇒ Object
Returns the value of attribute info.
4 5 6 |
# File 'lib/pgn/move_info_parser.rb', line 4 def info @info end |
#move ⇒ Object
Returns the value of attribute move.
4 5 6 |
# File 'lib/pgn/move_info_parser.rb', line 4 def move @move end |
#move_string ⇒ Object
Returns the value of attribute move_string.
4 5 6 |
# File 'lib/pgn/move_info_parser.rb', line 4 def move_string @move_string end |
Instance Method Details
#parse_move_string ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pgn/move_info_parser.rb', line 17 def parse_move_string info = {} info.merge!(extract_promotion) move_split = @move.split('.') info.merge!(basic_move_data(move_split)) return info if @castle move_string.tr!('+x:#', '') info.merge!(additional_info(move_string)) end |