Class: Bchess::PGN::MoveInfoParser

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#castleObject

Returns the value of attribute castle.



4
5
6
# File 'lib/pgn/move_info_parser.rb', line 4

def castle
  @castle
end

#infoObject

Returns the value of attribute info.



4
5
6
# File 'lib/pgn/move_info_parser.rb', line 4

def info
  @info
end

#moveObject

Returns the value of attribute move.



4
5
6
# File 'lib/pgn/move_info_parser.rb', line 4

def move
  @move
end

#move_stringObject

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_stringObject



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