class Handle
A handle to a scheduled timer.
Definitions
def initialize(time, block)
Initialize the handle with the given time and block.
Signature
-
parameter
time
Float
The time at which the block should be called.
-
parameter
block
Proc
The block to call.
Implementation
def initialize(time, block)
@time = time
@block = block
end
attr :time
Signature
-
attribute
Float
The time at which the block should be called.
attr :block
Signature
-
attribute
Proc | Nil
The block to call when the timer fires.
def < other
Compare the handle with another handle.
Signature
-
parameter
other
Handle
The other handle to compare with.
-
returns
Boolean
Whether the handle is less than the other handle.
Implementation
def < other
@time < other.time
end
def > other
Compare the handle with another handle.
Signature
-
parameter
other
Handle
The other handle to compare with.
-
returns
Boolean
Whether the handle is greater than the other handle.
Implementation
def > other
@time > other.time
end
def call(...)
Invoke the block.
Implementation
def call(...)
@block.call(...)
end
def cancel!
Cancel the timer.
Implementation
def cancel!
@block = nil
end
def cancelled?
Signature
-
returns
Boolean
Whether the timer has been cancelled.
Implementation
def cancelled?
@block.nil?
end