Class: Yaparc::ManyOne
- Inherits:
-
Object
- Object
- Yaparc::ManyOne
- Includes:
- Parsable
- Defined in:
- lib/yaparc/many_one.rb
Overview
requires at least one successfull application of parser.
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, identity = []) ⇒ ManyOne
constructor
A new instance of ManyOne.
Methods included from Parsable
Constructor Details
#initialize(parser, identity = []) ⇒ ManyOne
Returns a new instance of ManyOne.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/yaparc/many_one.rb', line 8 def initialize(parser, identity = []) @parser = lambda do |_input| Seq.new(parser, Many.new(parser, identity)) do |head, tail| case head when ::String, ::Array, ::Integer head + tail when ::Hash head.merge(tail) else if tail.nil? head else [head] + tail end end end end end |