Module: Elephrame::Scheduler
- Included in:
- Bots::GenerativeBot, Bots::PeriodInteract, Bots::Periodic, Bots::TraceryBot
- Defined in:
- lib/elephrame/rest/rest.rb
Instance Attribute Summary collapse
-
#schedule ⇒ Object
readonly
Returns the value of attribute schedule.
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
Instance Method Summary collapse
-
#run_scheduled ⇒ Object
(also: #run)
Runs the schedule.
-
#setup_scheduler(intv) ⇒ Object
Creates a new scheduler.
Instance Attribute Details
#schedule ⇒ Object (readonly)
Returns the value of attribute schedule.
4 5 6 |
# File 'lib/elephrame/rest/rest.rb', line 4 def schedule @schedule end |
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
3 4 5 |
# File 'lib/elephrame/rest/rest.rb', line 3 def scheduler @scheduler end |
Instance Method Details
#run_scheduled ⇒ Object Also known as: run
Runs the schedule. Requires a block to be passed to it.
21 22 23 24 25 26 27 |
# File 'lib/elephrame/rest/rest.rb', line 21 def run_scheduled @scheduler.repeat @interval do |j| @schedule = j yield(self) end @scheduler.join if @streamer.nil? end |
#setup_scheduler(intv) ⇒ Object
Creates a new scheduler
10 11 12 13 14 15 16 |
# File 'lib/elephrame/rest/rest.rb', line 10 def setup_scheduler intv require 'rufus-scheduler' @interval = intv @scheduler = Rufus::Scheduler.new end |