Class: Sashite::PAN::Parser
Overview
Parser class
Instance Attribute Summary
Attributes inherited from Action
#dst_square, #piece_hand, #piece_name, #src_square
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(serialized_action) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(serialized_action) ⇒ Parser
Returns a new instance of Parser.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sashite/pan/parser.rb', line 14 def initialize(serialized_action) super() action_args = serialized_action.split(separator) src_square = action_args.fetch(0) @src_square = src_square.eql?(drop_char) ? nil : Integer(src_square) @dst_square = Integer(action_args.fetch(1)) @piece_name = action_args.fetch(2) @piece_hand = action_args.fetch(3, nil) end |
Class Method Details
.call(serialized_move) ⇒ Object
9 10 11 12 |
# File 'lib/sashite/pan/parser.rb', line 9 def self.call(serialized_move) serialized_move.split(separator) .map { |serialized_action| new(serialized_action).call } end |
Instance Method Details
#call ⇒ Object
25 26 27 |
# File 'lib/sashite/pan/parser.rb', line 25 def call [src_square, dst_square, piece_name, piece_hand] end |