Class: PortableMoveNotation::Action::Load
- Inherits:
-
Object
- Object
- PortableMoveNotation::Action::Load
- Defined in:
- lib/portable_move_notation/action/load.rb
Instance Attribute Summary collapse
-
#serialized_action ⇒ Object
readonly
Returns the value of attribute serialized_action.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(serialized_action) ⇒ Load
constructor
A new instance of Load.
Constructor Details
#initialize(serialized_action) ⇒ Load
Returns a new instance of Load.
14 15 16 |
# File 'lib/portable_move_notation/action/load.rb', line 14 def initialize(serialized_action) @serialized_action = serialized_action end |
Instance Attribute Details
#serialized_action ⇒ Object (readonly)
Returns the value of attribute serialized_action.
12 13 14 |
# File 'lib/portable_move_notation/action/load.rb', line 12 def serialized_action @serialized_action end |
Class Method Details
.call(serialized_actions) ⇒ Object
6 7 8 9 10 |
# File 'lib/portable_move_notation/action/load.rb', line 6 def self.call(serialized_actions) serialized_actions.split(';').map do |serialized_action| new(serialized_action).call end end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/portable_move_notation/action/load.rb', line 18 def call action_args = serialized_action.split(',') src_square = action_args.fetch(0) src_square = src_square.eql?('*') ? nil : src_square.to_i dst_square = action_args.fetch(1).to_i piece_name = action_args.fetch(2) piece_hand = action_args.fetch(3, nil) [src_square, dst_square, piece_name, piece_hand] end |