Class: Farseer::Any

Inherits:
Object
  • Object
show all
Includes:
MapFactory
Defined in:
lib/farseer/any.rb

Instance Method Summary collapse

Methods included from MapFactory

#map

Constructor Details

#initialize(parser) ⇒ Any

Returns a new instance of Any.



7
8
9
10
# File 'lib/farseer/any.rb', line 7

def initialize(parser)
  @parser = parser
  freeze
end

Instance Method Details

#helper(input, tokens) ⇒ Object



16
17
18
19
20
# File 'lib/farseer/any.rb', line 16

def helper(input, tokens)
  @parser.parse(input)
         .bind { |r| helper(r.rest, tokens + r.token) }
         .map_none { Result.new(tokens, input) }
end

#parse(input) ⇒ Object



12
13
14
# File 'lib/farseer/any.rb', line 12

def parse(input)
  helper(input, '')
end