Class: Ztimer::Slot
- Inherits:
-
Object
- Object
- Ztimer::Slot
- Defined in:
- lib/ztimer/slot.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#enqueued_at ⇒ Object
readonly
Returns the value of attribute enqueued_at.
-
#executed_at ⇒ Object
Returns the value of attribute executed_at.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#recurrency ⇒ Object
readonly
Returns the value of attribute recurrency.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #cancel! ⇒ Object
- #canceled? ⇒ Boolean
-
#initialize(enqueued_at, expires_at, recurrency = -1,, &callback) ⇒ Slot
constructor
A new instance of Slot.
- #recurrent? ⇒ Boolean
- #reset! ⇒ Object
Constructor Details
#initialize(enqueued_at, expires_at, recurrency = -1,, &callback) ⇒ Slot
Returns a new instance of Slot.
7 8 9 10 11 12 13 14 15 |
# File 'lib/ztimer/slot.rb', line 7 def initialize(enqueued_at, expires_at,recurrency = -1, &callback) @enqueued_at = enqueued_at @expires_at = expires_at @recurrency = recurrency @callback = callback @started_at = nil @executed_at = nil @canceled = false end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
4 5 6 |
# File 'lib/ztimer/slot.rb', line 4 def callback @callback end |
#enqueued_at ⇒ Object (readonly)
Returns the value of attribute enqueued_at.
4 5 6 |
# File 'lib/ztimer/slot.rb', line 4 def enqueued_at @enqueued_at end |
#executed_at ⇒ Object
Returns the value of attribute executed_at.
5 6 7 |
# File 'lib/ztimer/slot.rb', line 5 def executed_at @executed_at end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
4 5 6 |
# File 'lib/ztimer/slot.rb', line 4 def expires_at @expires_at end |
#recurrency ⇒ Object (readonly)
Returns the value of attribute recurrency.
4 5 6 |
# File 'lib/ztimer/slot.rb', line 4 def recurrency @recurrency end |
#started_at ⇒ Object
Returns the value of attribute started_at.
5 6 7 |
# File 'lib/ztimer/slot.rb', line 5 def started_at @started_at end |
Instance Method Details
#<=>(other) ⇒ Object
35 36 37 |
# File 'lib/ztimer/slot.rb', line 35 def <=>(other) return @expires_at <=> other.expires_at end |
#cancel! ⇒ Object
31 32 33 |
# File 'lib/ztimer/slot.rb', line 31 def cancel! @canceled = true end |
#canceled? ⇒ Boolean
27 28 29 |
# File 'lib/ztimer/slot.rb', line 27 def canceled? return @canceled end |
#recurrent? ⇒ Boolean
17 18 19 |
# File 'lib/ztimer/slot.rb', line 17 def recurrent? return @recurrency > 0 end |
#reset! ⇒ Object
21 22 23 24 25 |
# File 'lib/ztimer/slot.rb', line 21 def reset! if recurrent? @expires_at += recurrency end end |