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 Attribute Summary
Attributes included from Parsable
Instance Method Summary collapse
-
#initialize(parser, &block) ⇒ Apply
constructor
A new instance of Apply.
Methods included from Parsable
Constructor Details
#initialize(parser, &block) ⇒ Apply
Returns a new instance of Apply.
230 231 232 233 234 235 236 237 238 239 |
# File 'lib/yaparc.rb', line 230 def initialize(parser, &block) @parser = lambda do |input| result = parser.parse(input) if result.instance_of?(Result::OK) Succeed.new(yield(result.value)).parse(result.input) else Fail.new.parse(input) end end end |