Class: CmdParse::CommandHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/cmdparse.rb

Overview

Command Hash - will return partial key matches as well if there is a single non-ambigous matching key

Instance Method Summary collapse

Instance Method Details

#[](cmd_name) ⇒ Object

:nodoc:



121
122
123
124
125
126
# File 'lib/cmdparse.rb', line 121

def [](cmd_name) #:nodoc:
  super || begin
    possible = keys.select {|key| key[0, cmd_name.length] == cmd_name }
    fetch(possible[0]) if possible.size == 1
  end
end

#key?(name) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


117
118
119
# File 'lib/cmdparse.rb', line 117

def key?(name) #:nodoc:
  !self[name].nil?
end