Class: PortableMoveNotation::Parser

Inherits:
Move
  • Object
show all
Defined in:
lib/portable_move_notation/parser.rb

Overview

Parser class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_actionsObject (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

#callObject



19
20
21
# File 'lib/portable_move_notation/parser.rb', line 19

def call
  serialized_actions.flat_map { |string| action_items(*string.split(',')) }
end