Class: IO::Event::Timers::Handle
- Inherits:
-
Object
- Object
- IO::Event::Timers::Handle
- Defined in:
- lib/io/event/timers.rb
Overview
A handle to a scheduled timer.
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
- #The block to call when the timer fires.(blocktocall) ⇒ Object readonly
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#<(other) ⇒ Object
Compare the handle with another handle.
-
#>(other) ⇒ Object
Compare the handle with another handle.
-
#call ⇒ Object
Invoke the block.
-
#cancel! ⇒ Object
Cancel the timer.
- #cancelled? ⇒ Boolean
-
#initialize(time, block) ⇒ Handle
constructor
Initialize the handle with the given time and block.
- #The time at which the block should be called.=(timeatwhichtheblockshouldbecalled. = (value)) ⇒ Object
Constructor Details
#initialize(time, block) ⇒ Handle
Initialize the handle with the given time and block.
18 19 20 21 |
# File 'lib/io/event/timers.rb', line 18 def initialize(time, block) @time = time @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
27 28 29 |
# File 'lib/io/event/timers.rb', line 27 def block @block end |
#The block to call when the timer fires.(blocktocall) ⇒ Object (readonly)
27 |
# File 'lib/io/event/timers.rb', line 27 attr :block |
#time ⇒ Object (readonly)
Returns the value of attribute time.
24 25 26 |
# File 'lib/io/event/timers.rb', line 24 def time @time end |
Instance Method Details
#<(other) ⇒ Object
Compare the handle with another handle.
33 34 35 |
# File 'lib/io/event/timers.rb', line 33 def < other @time < other.time end |
#>(other) ⇒ Object
Compare the handle with another handle.
41 42 43 |
# File 'lib/io/event/timers.rb', line 41 def > other @time > other.time end |
#call ⇒ Object
Invoke the block.
46 47 48 |
# File 'lib/io/event/timers.rb', line 46 def call(...) @block.call(...) end |
#cancel! ⇒ Object
Cancel the timer.
51 52 53 |
# File 'lib/io/event/timers.rb', line 51 def cancel! @block = nil end |
#cancelled? ⇒ Boolean
56 57 58 |
# File 'lib/io/event/timers.rb', line 56 def cancelled? @block.nil? end |
#The time at which the block should be called.=(timeatwhichtheblockshouldbecalled. = (value)) ⇒ Object
24 |
# File 'lib/io/event/timers.rb', line 24 attr :time |