class PortableMoveNotation::Parser
Parser
class
Attributes
serialized_actions[R]
Public Class Methods
call(string)
click to toggle source
# File lib/portable_move_notation/parser.rb, line 8 def self.call(string) string.split(separator) .map { |serialized_move| new(serialized_move).call } end
new(serialized_move)
click to toggle source
# File lib/portable_move_notation/parser.rb, line 15 def initialize(serialized_move) @serialized_actions = serialized_move.split(';') end
Public Instance Methods
call()
click to toggle source
# File lib/portable_move_notation/parser.rb, line 19 def call serialized_actions.flat_map { |string| action_items(*string.split(',')) } end
Private Instance Methods
action_items(*args)
click to toggle source
# File lib/portable_move_notation/parser.rb, line 25 def action_items(*args) src_square = args.fetch(0) src_square = src_square.eql?(drop_char) ? nil : Integer(src_square) dst_square = Integer(args.fetch(1)) piece_name = args.fetch(2) piece_hand = args.fetch(3, nil) [src_square, dst_square, piece_name, piece_hand] end
drop_char()
click to toggle source
# File lib/portable_move_notation/parser.rb, line 35 def drop_char '*' end