Class: Farseer::Many
Instance Method Summary collapse
- #helper(input, tokens) ⇒ Object
-
#initialize(parser) ⇒ Many
constructor
A new instance of Many.
- #parse(input) ⇒ Object
Methods included from MapFactory
Constructor Details
#initialize(parser) ⇒ Many
Returns a new instance of Many.
7 8 9 10 |
# File 'lib/farseer/many.rb', line 7 def initialize(parser) @parser = parser freeze end |
Instance Method Details
#helper(input, tokens) ⇒ Object
17 18 19 20 21 |
# File 'lib/farseer/many.rb', line 17 def helper(input, tokens) parse(input) .bind { |r| helper(r.rest, tokens + r.token) } .map_none { Result.new(tokens, input) } end |
#parse(input) ⇒ Object
12 13 14 15 |
# File 'lib/farseer/many.rb', line 12 def parse(input) @parser.parse(input) .bind { |r| helper(r.rest, r.token) } end |