Class: Yaparc::Apply
Constant Summary
Constants included from Parsable
Parsable::IS_ALPHANUM, Parsable::IS_CR, Parsable::IS_DIGIT, Parsable::IS_LOWER, Parsable::IS_SPACE, Parsable::IS_WHITESPACE
Instance Method Summary collapse
-
#initialize(parser) ⇒ Apply
constructor
A new instance of Apply.
Methods included from Parsable
Constructor Details
#initialize(parser) ⇒ Apply
Returns a new instance of Apply.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/yaparc/apply.rb', line 7 def initialize(parser) @parser = lambda do |input| result = parser.parse(input) if result.instance_of?(OK) Succeed.new(yield(result.value)).parse(result.input) else FailParser.new.parse(input) end end end |