Class: Yaparc::NoFail
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) ⇒ NoFail
constructor
A new instance of NoFail.
Methods included from Parsable
Constructor Details
#initialize(parser, &block) ⇒ NoFail
Returns a new instance of NoFail.
132 133 134 135 136 137 138 139 140 141 |
# File 'lib/yaparc.rb', line 132 def initialize(parser, &block) @parser = lambda do |input| result = parser.parse(input) if result.instance_of?(Result::Fail) Result::Error.new(:value => result.value, :input => result.input) else Succeed.new(result.value) end end end |