Class: Allora::Job::CronJob

Inherits:
Allora::Job show all
Defined in:
lib/allora/job/cron_job.rb

Overview

A classic cron style job, with support for seconds.

Instance Attribute Summary

Attributes inherited from Allora::Job

#block

Instance Method Summary collapse

Methods inherited from Allora::Job

#execute

Constructor Details

#initialize(cron_str, &block) ⇒ CronJob

Initialize the CronJob with the given cron string.

Examples:

CronJob.new("*/5 * * * * *") # every 5s
CronJob.new("0,30 * * * *")  # the 0th and 30th min of each hour
CronJob.new("0 3-6 * * *")   # on the hour, every hour between 3am and 6am

Parameters:

  • cron_str (String)

    any valid cron string, which may include seconds



36
37
38
39
40
# File 'lib/allora/job/cron_job.rb', line 36

def initialize(cron_str, &block)
  super(&block)

  @cron_line = CronLine.new(cron_str)
end

Instance Method Details

#next_at(from_time) ⇒ Object



42
43
44
# File 'lib/allora/job/cron_job.rb', line 42

def next_at(from_time)
  @cron_line.next_time(from_time)
end