Class: CmdParse::CommandHash
- Inherits:
-
Hash
- Object
- Hash
- CmdParse::CommandHash
- 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
-
#[](cmd_name) ⇒ Object
:nodoc:.
-
#key?(name) ⇒ Boolean
:nodoc:.
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:
117 118 119 |
# File 'lib/cmdparse.rb', line 117 def key?(name) #:nodoc: !self[name].nil? end |