Class: Appli::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/appli/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ Command

Returns a new instance of Command.



4
5
6
# File 'lib/appli/command.rb', line 4

def initialize(block)
  (class << self;self end).send :define_method, :command, &block
end

Instance Method Details

#call(options, *args) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/appli/command.rb', line 12

def call(options, *args)
  @options = options
  arity = method(:command).arity
  args << nil while args.size < arity
  send :command, *args
rescue Error => e
  puts "An error occured while excuting your command...\n#{e.message}"
end

#debug?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/appli/command.rb', line 8

def debug?
  false
end