Class: God::TimedEvent
Overview
The TimedEvent class represents an event in the future. This class is used by the drivers to schedule upcoming conditional tests and other scheduled events.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#at ⇒ Object
The Time at which this event is due.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compare this event to another.
-
#due? ⇒ Boolean
Is the current event due (current time >= event time)?.
-
#initialize(delay = 0) ⇒ TimedEvent
constructor
Instantiate a new TimedEvent that will be triggered after the specified delay.
Constructor Details
#initialize(delay = 0) ⇒ TimedEvent
Instantiate a new TimedEvent that will be triggered after the specified delay.
delay - The optional Numeric number of seconds from now at which to
trigger (default: 0).
23 24 25 |
# File 'lib/god/driver.rb', line 23 def initialize(delay = 0) self.at = Time.now + delay end |
Instance Attribute Details
#at ⇒ Object
The Time at which this event is due.
16 17 18 |
# File 'lib/god/driver.rb', line 16 def at @at end |
Instance Method Details
#<=>(other) ⇒ Object
Compare this event to another.
other - The other TimedEvent.
Returns -1 if this event is before the other, 0 if the two events are
due at the same time, 1 if the other event is later.
40 41 42 |
# File 'lib/god/driver.rb', line 40 def <=>(other) self.at <=> other.at end |
#due? ⇒ Boolean
Is the current event due (current time >= event time)?
Returns true if the event is due, false if not.
30 31 32 |
# File 'lib/god/driver.rb', line 30 def due? Time.now >= self.at end |