Class: CmdParse::CommandHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/module_cmdparse/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



115
116
117
118
119
120
# File 'lib/module_cmdparse/cmdparse.rb', line 115

def []( cmd_name )
    super or begin
        possible = keys.select {|key| key =~ /^#{cmd_name}.*/ }
        fetch( possible[0] ) if possible.size == 1
    end
end