Class: Docopt::Either
- Inherits:
-
ParentPattern
- Object
- Pattern
- ParentPattern
- Docopt::Either
- Defined in:
- lib/docopt.rb
Instance Attribute Summary
Attributes inherited from ParentPattern
Attributes inherited from Pattern
Instance Method Summary collapse
Methods inherited from ParentPattern
Methods inherited from Pattern
#==, #dump, #either, #fix, #fix_identities, #fix_repeating_arguments, #to_str
Constructor Details
This class inherits a constructor from Docopt::ParentPattern
Instance Method Details
#match(left, collected = nil) ⇒ Object
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/docopt.rb', line 355 def match(left, collected=nil) collected ||= [] outcomes = [] for p in self.children matched, _, _ = found = p.match(left, collected) if matched outcomes << found end end if outcomes.count > 0 return outcomes.min_by do |outcome| outcome[1] == nil ? 0 : outcome[1].count end end return [false, left, collected] end |