Class: Noir::Base::Command
- Inherits:
-
Object
- Object
- Noir::Base::Command
show all
- Defined in:
- lib/noir/base/command.rb
Class Method Summary
collapse
Class Method Details
.check_command_not_found(command = nil, *args) ⇒ Object
37
38
39
40
41
|
# File 'lib/noir/base/command.rb', line 37
def check_command_not_found command=nil, *args
return if command.nil?
raise 'command not found : ' + command
end
|
.description ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/noir/base/command.rb', line 6
def description
if @description.nil?
raise "Undefined description : " + self.to_s
else
puts self.to_s.split(':').last.downcase.ljust(15) + " : " + @description
end
end
|
.execute(*args) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/noir/base/command.rb', line 14
def execute *args
if self == Noir::Base::Command
raise 'called raw Noir::Base::Command.execute. please call it in extended class.'
end
check_command_not_found(*args)
description
puts '-- sub commands --'
sub_commands.map{|c|eval(self.to_s + '::' + c.to_s)}.each{|c| c.description}
end
|
.sub_commands ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/noir/base/command.rb', line 28
def sub_commands
consts = constants - superclass.constants
consts = consts.select do |const|
const_get(const).class == Class &&
const_get(const).ancestors.include?(Noir::Base::Command)
end
consts.sort
end
|