Top Level Namespace

Defined Under Namespace

Modules: Rubysh

Instance Method Summary collapse

Instance Method Details

#AliasRubysh(name) ⇒ Object



84
85
86
87
88
# File 'lib/rubysh.rb', line 84

def AliasRubysh(name)
  metaclass = class << self; self; end
  metaclass.send(:alias_method, name, :Rubysh)
  Object.const_set(name, Rubysh)
end

#Rubysh(*args, &blk) ⇒ Object

Either create a new Rubysh command:

command = Rubysh('ls')
command.run

Or use the block syntax to create and run one:

Rubysh {'ls'}


73
74
75
76
77
78
79
80
81
82
# File 'lib/rubysh.rb', line 73

def Rubysh(*args, &blk)
  if blk
    raise Rubysh::Error::BaseError.new("Can't provide arguments and a block") if args.length > 0
    command = blk.call
    command = Rubysh::Command.new(command) unless command.kind_of?(Rubysh::Command)
    command.run
  else
    Rubysh::Command.new(args)
  end
end