Class: ShellB::Commander

Inherits:
Object
  • Object
show all
Defined in:
lib/shellb/commander.rb

Constant Summary collapse

DEFAULT_COMMANDS =
%w[
  cd
  pwd
].each do |cmd|
  def_system_command(cmd)
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shell) ⇒ Commander

Returns a new instance of Commander.



28
29
30
# File 'lib/shellb/commander.rb', line 28

def initialize(shell)
  @shell = shell
end

Instance Attribute Details

#shellObject (readonly)

Returns the value of attribute shell.



5
6
7
# File 'lib/shellb/commander.rb', line 5

def shell
  @shell
end

Class Method Details

.alias_command(name, *args) ⇒ Object



14
15
16
17
18
# File 'lib/shellb/commander.rb', line 14

def alias_command(name, *args)
  define_method(name) do |*opts|
    Command.new(shell, *args, *opts)
  end
end

.def_system_command(name, path = nil) ⇒ Object



8
9
10
11
12
# File 'lib/shellb/commander.rb', line 8

def def_system_command(name, path = nil)
  define_method(name) do |*args|
    Command.new(shell, path || name, *args)
  end
end