Class: SimpleKit::EventScheduler::EventNotice
- Inherits:
-
Object
- Object
- SimpleKit::EventScheduler::EventNotice
- Includes:
- Comparable
- Defined in:
- lib/simplekit.rb
Overview
This is a private helper class for the EventScheduler class. Users should never try to access this directly.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#time_stamp ⇒ Object
readonly
Returns the value of attribute time_stamp.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compare EventNotice objects for ordering, first by time, breaking ties using priority.
-
#initialize(event, time, delay, args) ⇒ EventNotice
constructor
A new instance of EventNotice.
Constructor Details
#initialize(event, time, delay, args) ⇒ EventNotice
Returns a new instance of EventNotice.
139 140 141 142 143 144 145 |
# File 'lib/simplekit.rb', line 139 def initialize(event, time, delay, args) @event = event @time_stamp = time @time = time + delay @args = args @priority = @args && @args.key?(:priority) ? @args.delete(:priority) : 10 end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
137 138 139 |
# File 'lib/simplekit.rb', line 137 def args @args end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
137 138 139 |
# File 'lib/simplekit.rb', line 137 def event @event end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
137 138 139 |
# File 'lib/simplekit.rb', line 137 def priority @priority end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
137 138 139 |
# File 'lib/simplekit.rb', line 137 def time @time end |
#time_stamp ⇒ Object (readonly)
Returns the value of attribute time_stamp.
137 138 139 |
# File 'lib/simplekit.rb', line 137 def time_stamp @time_stamp end |
Instance Method Details
#<=>(other) ⇒ Object
Compare EventNotice objects for ordering, first by time, breaking ties using priority.
150 151 152 153 154 |
# File 'lib/simplekit.rb', line 150 def <=>(other) (time <=> other.time).tap do |outcome| return priority <=> other.priority if outcome == 0 end end |