Class | Timer
In: | lib/rbot/timer.rb
Parent: | Object

Timer handler, manage multiple Action objects, calling them when required. When the Timer is constructed, a new Thread is created to manage timed delays and run Actions.

XXX: there is no way to stop the timer currently. I‘m keeping it this way to weed out old Timer implementation legacy in rbot code. -jsn.

### Methods

[] add add_once block configure delete new remove reschedule run_actions start stop unblock

### Classes and Modules

Class Timer::Action

### Public Class methods

new()

creates a new Timer and starts it.

### Public Instance methods

add(period, opts = {}, &block)

Creates and installs a new Action, repeatable by default.

period: | Action period
opts: | options for Action#new, see there
block: | Action callback code

Returns the id of the created Action

add_once(period, opts = {}, &block)

Creates and installs a new Action, one-time by default.

period: | Action delay
opts: | options for Action#new, see there
block: | Action callback code

Returns the id of the created Action

block(aid)

blocks an existing Action

aid: | Action id, obtained previously from add() or add_once()

configure(aid, opts = {}, &block)

Provides for on-the-fly reconfiguration of Actions

aid: | Action id, obtained previously from add() or add_once()
opts: | see Action#new
block: | (optional) new Action callback code

delete(aid)

Alias for remove

remove(aid)

removes an existing blocked Action

aid: | Action id, obtained previously from add() or add_once()

reschedule(aid, period, &block)

changes Action period

aid: | Action id
period: | new period
block: | (optional) new Action callback code

start()
stop()
unblock(aid)

unblocks an existing blocked Action

aid: | Action id, obtained previously from add() or add_once()

### Protected Instance methods

[](aid)
run_actions(now = Time.now)

[Validate]