Class: UV::Timer

Inherits:
Object
  • Object
show all
Includes:
Assertions, Handle
Defined in:
lib/uv/timer.rb

Instance Method Summary collapse

Methods included from Assertions

#assert_arity, #assert_block, #assert_boolean, #assert_signal, #assert_type

Methods included from Handle

#active?, close, #close, #closing?, #initialize, #ref, #unref

Methods included from Resource

#check_result, #check_result!, #to_ptr

Methods included from Listener

define_callback, undefine_callbacks

Instance Method Details

#againObject



24
25
26
27
28
# File 'lib/uv/timer.rb', line 24

def again
  check_result! UV.timer_again(handle)

  self
end

#repeatObject



38
39
40
# File 'lib/uv/timer.rb', line 38

def repeat
  UV.timer_get_repeat(handle)
end

#repeat=(repeat) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/uv/timer.rb', line 30

def repeat=(repeat)
  assert_type(Integer, repeat, "repeat must be an Integer")

  check_result! UV.timer_set_repeat(handle, repeat)

  self
end

#start(timeout, repeat, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/uv/timer.rb', line 5

def start(timeout, repeat, &block)
  assert_block(block)
  assert_arity(1, block)
  assert_type(Integer, timeout, "timeout must be an Integer")
  assert_type(Integer, repeat, "repeat must be an Integer")

  @timer_block = block

  check_result! UV.timer_start(handle, callback(:on_timer), timeout, repeat)

  self
end

#stopObject



18
19
20
21
22
# File 'lib/uv/timer.rb', line 18

def stop
  check_result! UV.timer_stop(handle)

  self
end