Module: Muby::HelperMethods
Constant Summary
Constants included
from Styled
Styled::ALTCHARSET, Styled::BLACK, Styled::BLINK, Styled::BLUE, Styled::BOLD, Styled::CHARTEXT, Styled::CYAN, Styled::DIM, Styled::GREEN, Styled::INVIS, Styled::MAGENTA, Styled::NORMAL, Styled::PROTECT, Styled::RED, Styled::REVERSE, Styled::STANDOUT, Styled::UNDERLINE, Styled::WHITE, Styled::YELLOW
Instance Method Summary
collapse
Instance Method Details
#do_execute(command, *args) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/muby/helper_methods.rb', line 12
def do_execute(command, *args)
result = nil
if command.respond_to?(:call)
result = command.call(*args[0...(command.arity)])
elsif String === command
result = eval(command)
elsif Symbol === command
method = self.method(command)
args = args[0...(method.arity)]
result = method.call(*args)
elsif Array === command
method = self.method(command.first)
args = (command[1..-1] + args)[0...(method.arity)]
result = method.call(*args)
else
result = command
end
result
end
|
#execute(command, *args) ⇒ Object
8
9
10
|
# File 'lib/muby/helper_methods.rb', line 8
def execute(command, *args)
execute_with_verbosity(:debug, command, *args)
end
|
#execute_with_verbosity(verbosity, command, *args) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/muby/helper_methods.rb', line 32
def execute_with_verbosity(verbosity, command, *args)
begin
result = do_execute(command, *args)
unless result.nil?
case result
when String
Muby::OutputWindow.get_instance.show(verbosity, result)
else
Muby::OutputWindow.get_instance.show(verbosity, result.inspect)
end
end
result
rescue SystemExit => ex
quit
rescue Exception => e
exception(e)
end
end
|