class EventCore::TimeoutSource
A source that fires the trigger depending on a timeout.
Public Class Methods
new(secs)
click to toggle source
Calls superclass method
EventCore::Source::new
# File lib/event_core.rb, line 314 def initialize(secs) super() @timeout_secs = secs @next_timestamp = Time.now.to_f + secs end
Public Instance Methods
ready?()
click to toggle source
# File lib/event_core.rb, line 320 def ready? return true if @ready now = Time.now.to_f if now >= @next_timestamp ready! @next_timestamp = now + @timeout_secs return true end false end
timeout()
click to toggle source
# File lib/event_core.rb, line 332 def timeout delta = @next_timestamp - Time.now.to_f delta > 0 ? delta : 0 end