Module: Elephrame::Scheduler

Included in:
Bots::PeriodInteract, Bots::Periodic
Defined in:
lib/elephrame/rest/rest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scheduleObject (readonly)

Returns the value of attribute schedule


4
5
6
# File 'lib/elephrame/rest/rest.rb', line 4

def schedule
  @schedule
end

#schedulerObject (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_scheduledObject 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 unless not @streamer.nil?
end

#setup_scheduler(intv) ⇒ Object

Creates a new scheduler

Parameters:

  • intv (String)

    string specifying interval to post


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