Class: DocoptNG::Optional

Inherits:
ParentPattern show all
Defined in:
lib/docopt_ng/optional.rb

Direct Known Subclasses

AnyOptions

Instance Attribute Summary

Attributes inherited from ParentPattern

#children

Attributes inherited from Pattern

#children

Instance Method Summary collapse

Methods inherited from ParentPattern

#flat, #initialize, #inspect

Methods inherited from Pattern

#==, #dump, #either, #fix, #fix_identities, #fix_repeating_arguments, #to_str

Constructor Details

This class inherits a constructor from DocoptNG::ParentPattern

Instance Method Details

#match(left, collected = nil) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/docopt_ng/optional.rb', line 5

def match(left, collected = nil)
  collected ||= []
  children.each do |p|
    _, left, collected = p.match(left, collected)
  end
  [true, left, collected]
end