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