Class Rufus::Scheduler::SchedulerCore
In: lib/rufus/sc/scheduler.rb
Parent: Object

The core of a rufus-scheduler. See implementations like Rufus::Scheduler::PlainScheduler and Rufus::Scheduler::EmScheduler for directly usable stuff.

Methods

Included Modules

LegacyMethods

Attributes

options  [R]  classical options hash

Public Class methods

Instantiates and starts a new Rufus::Scheduler.

Public Instance methods

Returns a map job_id => job of all the jobs currently in the scheduler

Schedules a job at a given point in time.

  scheduler.at 'Thu Mar 26 19:30:00 2009' do
    puts 'order pizza'
  end

pizza is for Thursday at 2000 (if the shop brochure is right).

Schedules a job given a cron string.

  scheduler.cron '0 22 * * 1-5' do
    # every day of the week at 00:22
    puts 'activate security system'
  end

Returns a map job_id => job for cron jobs

Schedules a recurring job every t.

  scheduler.every '5m1w' do
    puts 'check blood pressure'
  end

checking blood pressure every 5 months and 1 week.

Returns a list of jobs with the given tag

Feel free to override this method. The default implementation simply outputs the error message to STDOUT

Schedules a job in a given amount of time.

  scheduler.in '20m' do
    puts "order ristretto"
  end

will order an espresso (well sort of) in 20 minutes.

Returns a map job_id => job for at/in/every jobs

schedule(cronstring, s=nil, opts={}, &block)

Alias for cron

schedule_at(t, s=nil, opts={}, &block)

Alias for at

schedule_every(t, s=nil, opts={}, &block)

Alias for every

schedule_in(t, s=nil, opts={}, &block)

Alias for in

Unschedules a job (cron or at/every/in job) given its id.

Returns the job that got unscheduled.

Protected Instance methods

Raises an error if the job has the params :blocking and :timeout set

Returns a job queue instance.

(made it into a method for easy override)

The method that does the "wake up and trigger any job that should get triggered.

The default, plain, implementation. If ‘blocking’ is true, will simply call the block and return when the block is done. Else, it will call the block in a dedicated thread.

TODO : clarify, the blocking here blocks the whole scheduler, while EmScheduler blocking triggers for the next tick. Not the same thing …

[Validate]