Class: Gamelan::Task
- Inherits:
-
Object
- Object
- Gamelan::Task
- Extended by:
- Forwardable
- Defined in:
- lib/gamelan/task.rb
Overview
Tasks run by the Scheduler. A task is a combination of a block to be run, a delay, in beats, that specifies when to run the Task, and an optional list of args. A reference to the Scheduler is also stored, so it can be manipulatd by tasks.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
Instance Method Summary collapse
-
#initialize(sched, delay, *args, &block) ⇒ Task
constructor
Construct a Task with a Scheduler reference, a delay in beats, an optional list of args, and a block.
-
#run ⇒ Object
The scheduler will invoke Task#run is called with the Task’s
delay
at the scheduled time.
Constructor Details
#initialize(sched, delay, *args, &block) ⇒ Task
Construct a Task with a Scheduler reference, a delay in beats, an optional list of args, and a block.
16 17 18 |
# File 'lib/gamelan/task.rb', line 16 def initialize(sched, delay, *args, &block) @scheduler, @delay, @proc, @args = sched, delay, block, args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
12 13 14 |
# File 'lib/gamelan/task.rb', line 12 def args @args end |
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
12 13 14 |
# File 'lib/gamelan/task.rb', line 12 def delay @delay end |
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
12 13 14 |
# File 'lib/gamelan/task.rb', line 12 def scheduler @scheduler end |
Instance Method Details
#run ⇒ Object
The scheduler will invoke Task#run is called with the Task’s delay
at the scheduled time. Any optional args
, if given, will follow. are yielded to the block.
23 |
# File 'lib/gamelan/task.rb', line 23 def run; @proc[@delay, *@args] end |