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_list_arguments, #to_str
Constructor Details
This class inherits a constructor from Docopt::ParentPattern
Instance Method Details
#match(left, collected = nil) ⇒ Object
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/docopt.rb', line 331 def match(left, collected=nil) collected ||= [] outcomes = [] for p in self.children matched, _, _ = outcome = p.match(left, collected) if matched outcomes << outcome end end if outcomes.count > 0 ret = outcomes.min_by do |outcome| outcome[1] == nil ? 0 : outcome[1].count end return ret end return [false, left, collected] end |