Class: Allora::Job::EveryJob

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

Overview

A very simple job type that simply repeats every n seconds.

Instance Attribute Summary

Attributes inherited from Allora::Job

#block

Instance Method Summary collapse

Methods inherited from Allora::Job

#execute

Constructor Details

#initialize(n, &block) ⇒ EveryJob

Initialize the job to run every n seconds.

You may use ActiveSupport’s numeric helpers, if you have ActiveSupport available.

Examples:

Using ActiveSupport

EveryJob.new(15.seconds) { puts "Boo!" }


38
39
40
41
42
# File 'lib/allora/job/every_job.rb', line 38

def initialize(n, &block)
  @duration = n

  super(&block)
end

Instance Method Details

#next_at(from_time) ⇒ Object



44
45
46
# File 'lib/allora/job/every_job.rb', line 44

def next_at(from_time)
  from_time + @duration
end