Class: DocoptNG::Command

Inherits:
Argument show all
Defined in:
lib/docopt_ng/command.rb

Instance Attribute Summary

Attributes inherited from ChildPattern

#name, #value

Attributes inherited from Pattern

#children

Instance Method Summary collapse

Methods inherited from Argument

parse

Methods inherited from ChildPattern

#flat, #inspect, #match

Methods inherited from Pattern

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

Constructor Details

#initialize(name, value = false) ⇒ Command

Returns a new instance of Command.



5
6
7
8
# File 'lib/docopt_ng/command.rb', line 5

def initialize(name, value = false)
  @name = name
  @value = value
end

Instance Method Details

#single_match(left) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/docopt_ng/command.rb', line 10

def single_match(left)
  left.each_with_index do |p, n|
    next unless p.instance_of?(Argument)
    return n, Command.new(name, true) if p.value == name

    break
  end

  [nil, nil]
end