Module: Frankenpins::Utils
- Included in:
- Frankenpins, Pin
- Defined in:
- lib/frankenpins/utils.rb
Instance Method Summary collapse
-
#wait ⇒ Object
Prevents the main thread from exiting.
- #watch(&block) ⇒ Object
Instance Method Details
#wait ⇒ Object
Prevents the main thread from exiting. Required when using PiPiper.watch
4 5 6 |
# File 'lib/frankenpins/utils.rb', line 4 def wait loop do sleep 1 end end |
#watch(&block) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/frankenpins/utils.rb', line 8 def watch(&block) Thread.new do loop do wait_for_change block.call(self) end end.abort_on_exception = true end |