class Rufus::Scheduler::IntervalJob

Attributes

interval[R]

Public Class Methods

new(scheduler, interval, opts, block) click to toggle source
Calls superclass method Rufus::Scheduler::RepeatJob::new
# File lib/rufus/scheduler/jobs_repeat.rb, line 231
def initialize(scheduler, interval, opts, block)

  super(scheduler, interval, opts, block)

  @interval = Rufus::Scheduler.parse_in(@original)

  fail ArgumentError.new(
    "cannot schedule #{self.class} with an interval " +
    "of #{@interval.inspect} (#{@original.inspect})"
  ) if @interval <= 0

  set_next_time(nil)
end

Public Instance Methods

next_time_from(time) click to toggle source
# File lib/rufus/scheduler/jobs_repeat.rb, line 245
def next_time_from(time)

  time + @mean_work_time + @interval
end

Protected Instance Methods

set_next_time(trigger_time, is_post=false, now=nil) click to toggle source
# File lib/rufus/scheduler/jobs_repeat.rb, line 252
def set_next_time(trigger_time, is_post=false, now=nil)

  n = now || EoTime.now

  @next_time =
    if is_post
      n + @interval
    elsif trigger_time.nil?
      if @first_at == nil || @first_at < n
        n + @interval
      else
        @first_at
      end
    else
      false
    end
end