Class: CommandTimer::Command
- Inherits:
-
Object
- Object
- CommandTimer::Command
- Defined in:
- lib/command_timer/command.rb
Instance Attribute Summary collapse
- #burn_time ⇒ Object
-
#content ⇒ Object
Returns the value of attribute content.
-
#description ⇒ Object
Returns the value of attribute description.
-
#observer ⇒ Object
Returns the value of attribute observer.
Instance Method Summary collapse
Instance Attribute Details
#burn_time ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/command_timer/command.rb', line 8 def burn_time if @burn_time =~ /[0-9]{2}:[0-9]{2}:[0-9]{2}/ CommandTimer.parse_time(@burn_time) else @burn_time end end |
#content ⇒ Object
Returns the value of attribute content.
5 6 7 |
# File 'lib/command_timer/command.rb', line 5 def content @content end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/command_timer/command.rb', line 4 def description @description end |
#observer ⇒ Object
Returns the value of attribute observer.
6 7 8 |
# File 'lib/command_timer/command.rb', line 6 def observer @observer end |
Instance Method Details
#echo_command(prefix = '') ⇒ Object
24 25 26 27 28 |
# File 'lib/command_timer/command.rb', line 24 def echo_command(prefix = '') @content.split(';').each do |line| puts "#{prefix}>> #{line.strip.gsub('\\', '')}" end end |
#exec ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/command_timer/command.rb', line 16 def exec echo_command system @content if @observer run_observer end end |
#run_observer ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/command_timer/command.rb', line 30 def run_observer puts "========================================" puts "= Start observer, press <Ctrl-C> to stop it." puts "= #{@observer}" puts "========================================" system @observer puts "Observer stopped." end |