Class: CommandTimer::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/command_timer/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#burn_timeObject



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

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/command_timer/command.rb', line 5

def content
  @content
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/command_timer/command.rb', line 4

def description
  @description
end

#grepObject

Returns the value of attribute grep.



7
8
9
# File 'lib/command_timer/command.rb', line 7

def grep
  @grep
end

#observerObject

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

#execObject



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_observerObject



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