Class: PortableMoveNotation::Parser
- Defined in:
- lib/portable_move_notation/parser.rb
Overview
Parser class
Instance Attribute Summary collapse
-
#serialized_actions ⇒ Object
readonly
Returns the value of attribute serialized_actions.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(serialized_move) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(serialized_move) ⇒ Parser
Returns a new instance of Parser.
15 16 17 |
# File 'lib/portable_move_notation/parser.rb', line 15 def initialize(serialized_move) @serialized_actions = serialized_move.split(';') end |
Instance Attribute Details
#serialized_actions ⇒ Object (readonly)
Returns the value of attribute serialized_actions.
13 14 15 |
# File 'lib/portable_move_notation/parser.rb', line 13 def serialized_actions @serialized_actions end |
Class Method Details
.call(string) ⇒ Object
8 9 10 11 |
# File 'lib/portable_move_notation/parser.rb', line 8 def self.call(string) string.split(separator) .map { |serialized_move| new(serialized_move).call } end |
Instance Method Details
#call ⇒ Object
19 20 21 |
# File 'lib/portable_move_notation/parser.rb', line 19 def call serialized_actions.flat_map { |string| action_items(*string.split(',')) } end |