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.
-
#grep ⇒ Object
Returns the value of attribute grep.
-
#observer ⇒ Object
Returns the value of attribute observer.
Instance Method Summary collapse
Instance Attribute Details
#burn_time ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/command_timer/command.rb', line 9 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 |
#grep ⇒ Object
Returns the value of attribute grep.
7 8 9 |
# File 'lib/command_timer/command.rb', line 7 def grep @grep 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
25 26 27 28 29 |
# File 'lib/command_timer/command.rb', line 25 def echo_command(prefix = '') @content.split(';').each do |line| puts "#{prefix}>> #{line.strip.gsub('\\', '')}" end end |
#exec ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/command_timer/command.rb', line 17 def exec echo_command system @content if @observer run_observer end end |
#run_observer ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/command_timer/command.rb', line 31 def run_observer puts "========================================" puts "= Start observer, press <Ctrl-C> to stop it." puts "= #{@observer}" puts "========================================" system @observer puts "Observer stopped." end |