Method: Garcon.timer

Defined in:
lib/garcon/task/timer.rb

.timer(seconds, *args) { ... } ⇒ Boolean

Perform the given operation asynchronously after the given number of seconds.

Parameters:

  • seconds (Fixnum)

    The interval in seconds to wait before executing the task

Yields:

  • the task to execute

Returns:

Raises:

  • (ArgumentError)


34
35
36
37
38
39
40
41
42
# File 'lib/garcon/task/timer.rb', line 34

def timer(seconds, *args, &block)
  raise ArgumentError, 'no block given' unless block_given?
  if seconds < 0
    raise ArgumentError, 'interval must be greater than or equal to zero'
  end

  Garcon.global_timer_set.post(seconds, *args, &block)
  true
end