Class: CG::Command

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Command

Returns a new instance of Command.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cg/command.rb', line 5

def initialize(*args)
  Dir[File.join(File.dirname(__FILE__), "command", "*.rb")].each do |file|
    require file
  end

  namespace = args.shift.capitalize rescue nil
  namespace = Kernel.const_get("Command").const_get(namespace) rescue nil
  task      = args.shift.downcase rescue nil

  if namespace
    if task
      namespace.send(task, *args)
    else
      namespace.send("main", *args)
    end
  else
    puts CG::VERSION
  end
end