Class: Tasks
- Inherits:
-
Object
- Object
- Tasks
- Defined in:
- lib/tasks.rb
Constant Summary collapse
- @@default =
nil
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(value) ⇒ Object
- #execute_task(task) ⇒ Object
-
#initialize(env = nil) ⇒ Tasks
constructor
A new instance of Tasks.
Constructor Details
#initialize(env = nil) ⇒ Tasks
Returns a new instance of Tasks.
5 6 7 8 9 |
# File 'lib/tasks.rb', line 5 def initialize env=nil @@default=self @env=env @env=Environment.new if @env.nil? end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
2 3 4 |
# File 'lib/tasks.rb', line 2 def env @env end |
Class Method Details
Instance Method Details
#execute(value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tasks.rb', line 11 def execute value if(value.respond_to?(:execute)) value.update if value.respond_to?(:update) value.execute else if(value.is_a?(String)) puts `#{value}` else if(value.is_a?(Array)) value.each{|e| execute(e)} end end end end |
#execute_task(task) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tasks.rb', line 26 def execute_task task if(defined?(COMMANDS)) if(COMMANDS.has_key?(task)) puts ":#{task}" if !@env.colorize? if @env.colorize? require 'ansi/code' puts ANSI.white + ANSI.bold + ":#{task}" + ANSI.reset if @env.colorize? end execute(COMMANDS[task]) end end end |