Class: IO::Event::Timers::Handle

Inherits:
Object
  • Object
show all
Defined in:
lib/io/event/timers.rb

Overview

A handle to a scheduled timer.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#blockObject (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

#timeObject (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

#callObject

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

Returns:

  • (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