Class: Docopt::Command

Inherits:
Argument show all
Defined in:
lib/docopt.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.



218
219
220
221
# File 'lib/docopt.rb', line 218

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

Instance Method Details

#single_match(left) ⇒ Object



223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/docopt.rb', line 223

def single_match(left)
  left.each_with_index do |p, n|
    if p.class == Argument
      if p.value == self.name
        return n, Command.new(self.name, true)
      else
        break
      end
    end
  end
  return [nil, nil]
end