Class: Yaparc::Apply
Overview
class ApplyParser
Constant Summary
Constants included from Parsable
Parsable::IS_ALPHANUM, 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.
249 250 251 252 253 254 255 256 257 258 |
# File 'lib/yaparc.rb', line 249 def initialize(parser, &block) @parser = lambda do |input| case result = parser.parse(input) when Result::OK Succeed.new(yield(result.value)).parse(result.input) else Fail.new.parse(input) end end end |