Class: MisterBin::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/mister_bin/commands.rb

Overview

This class handles listing and finding command files

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#basedirObject (readonly)

Returns the value of attribute basedir.



5
6
7
# File 'lib/mister_bin/commands.rb', line 5

def basedir
  @basedir
end

#basenameObject (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

#allObject



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

#namesObject



16
17
18
# File 'lib/mister_bin/commands.rb', line 16

def names
  all.keys.sort
end