Class: Sysdo::EventSource::PolledChange
- Inherits:
-
Sysdo::EventSource
- Object
- Sysdo::EventSource
- Sysdo::EventSource::PolledChange
- Defined in:
- lib/sysdo/event_source/polled_change.rb
Instance Attribute Summary
Attributes inherited from Sysdo::EventSource
Instance Method Summary collapse
-
#initialize(poll_rate = 1, &value) ⇒ PolledChange
constructor
A new instance of PolledChange.
Methods inherited from Sysdo::EventSource
Constructor Details
#initialize(poll_rate = 1, &value) ⇒ PolledChange
Returns a new instance of PolledChange.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sysdo/event_source/polled_change.rb', line 4 def initialize(poll_rate = 1, &value) super() do |s| last = value.() loop do now = value.() if last != now s.fire(now) end last = now sleep poll_rate end end end |