Class: Tamarillo::Monitor
- Inherits:
-
Object
- Object
- Tamarillo::Monitor
- Defined in:
- lib/tamarillo/monitor.rb
Constant Summary collapse
- SLEEP_TIME =
The time between checks.
0.3
Instance Attribute Summary collapse
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
-
#initialize(tomato, notifier) ⇒ Monitor
constructor
Public: Initializes a new monitor.
-
#start ⇒ Object
Public: Starts watching a tomato for completion.
Constructor Details
#initialize(tomato, notifier) ⇒ Monitor
Public: Initializes a new monitor.
8 9 10 11 |
# File 'lib/tamarillo/monitor.rb', line 8 def initialize(tomato, notifier) @tomato = tomato @notifier = notifier end |
Instance Attribute Details
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
5 6 7 |
# File 'lib/tamarillo/monitor.rb', line 5 def pid @pid end |
Instance Method Details
#start ⇒ Object
Public: Starts watching a tomato for completion.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tamarillo/monitor.rb', line 14 def start @pid = fork do until @tomato.completed? sleep SLEEP_TIME end @notifier.call end Process.detach(@pid) end |