Class: KnocKnoc::WatchmanMonitor
- Defined in:
- lib/knoc-knoc/watchman_monitor.rb
Constant Summary
Constants inherited from Watchman
Instance Attribute Summary
Attributes inherited from Watchman
#whos_left, #whos_new, #whos_there
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize ⇒ WatchmanMonitor
constructor
A new instance of WatchmanMonitor.
- #repeat_every(interval, &block) ⇒ Object
Methods inherited from Watchman
local_ip, ping, ping_all, #refresh_lists, #update_new_ips, #update_whos_left
Constructor Details
#initialize ⇒ WatchmanMonitor
Returns a new instance of WatchmanMonitor.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/knoc-knoc/watchman_monitor.rb', line 5 def initialize super @running = true #run the refresh_lists once before #starting the set interval Thread.new() do self.refresh_lists self.repeat_every(30) do self.refresh_lists end end end |
Instance Method Details
#cleanup ⇒ Object
27 28 29 |
# File 'lib/knoc-knoc/watchman_monitor.rb', line 27 def cleanup @running = false end |
#repeat_every(interval, &block) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/knoc-knoc/watchman_monitor.rb', line 18 def repeat_every(interval, &block) while @running start_time = Time.now Thread.new(&block).join elapsed = Time.now - start_time sleep([interval - elapsed, 0].max) end end |