Class: DocoptNG::Required

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

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
12
13
14
15
# File 'lib/docopt_ng/required.rb', line 5

def match(left, collected = nil)
  collected ||= []
  l = left
  c = collected

  children.each do |p|
    matched, l, c = p.match(l, c)
    return [false, left, collected] unless matched
  end
  [true, l, c]
end