Class: MisterBin::Commands
- Inherits:
-
Object
- Object
- MisterBin::Commands
- Defined in:
- lib/mister_bin/commands.rb
Overview
This class handles listing and finding command files
Instance Attribute Summary collapse
-
#basedir ⇒ Object
readonly
Returns the value of attribute basedir.
-
#basename ⇒ Object
readonly
Returns the value of attribute basename.
Instance Method Summary collapse
- #all ⇒ Object
- #find(command, subcommand = nil) ⇒ Object
-
#initialize(basename, basedir = '.') ⇒ Commands
constructor
A new instance of Commands.
- #names ⇒ Object
Constructor Details
#initialize(basename, basedir = '.') ⇒ Commands
Returns a new instance of Commands.
7 8 9 10 |
# File 'lib/mister_bin/commands.rb', line 7 def initialize(basename, basedir='.') @basename = basename @basedir = basedir end |
Instance Attribute Details
#basedir ⇒ Object (readonly)
Returns the value of attribute basedir.
5 6 7 |
# File 'lib/mister_bin/commands.rb', line 5 def basedir @basedir end |
#basename ⇒ Object (readonly)
Returns the value of attribute basename.
5 6 7 |
# File 'lib/mister_bin/commands.rb', line 5 def basename @basename end |
Instance Method Details
#all ⇒ Object
12 13 14 |
# File 'lib/mister_bin/commands.rb', line 12 def all @all ||= all! end |
#find(command, subcommand = nil) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/mister_bin/commands.rb', line 20 def find(command, subcommand=nil) if subcommand and names.include? "#{command} #{subcommand}" all["#{command} #{subcommand}"] else all["#{command}"] end end |
#names ⇒ Object
16 17 18 |
# File 'lib/mister_bin/commands.rb', line 16 def names all.keys.sort end |