Sha256: f80bf420484da6c91e7cc448e0688765a0d42f1f53b35de17e6712d73342369a

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

class Rufus::Scheduler::OneTimeJob < Rufus::Scheduler::Job

  alias time next_time

  def occurrences(time0, time1)

    (time >= time0 && time <= time1) ? [ time ] : []
  end

  protected

  def determine_id

    [
      self.class.name.split(':').last.downcase[0..-4],
      @scheduled_at.to_f,
      @next_time.to_f,
      (self.object_id < 0 ? 'm' : '') + self.object_id.to_s
    ].map(&:to_s).join('_')
  end

  # There is no next_time for one time jobs, hence the false.
  #
  def set_next_time(trigger_time, is_post=false, now=nil)

    @next_time = is_post ? nil : false
  end
end

class Rufus::Scheduler::AtJob < Rufus::Scheduler::OneTimeJob

  def initialize(scheduler, time, opts, block)

    super(scheduler, time, opts, block)

    @next_time =
      opts[:_t] || Rufus::Scheduler.parse_at(time, opts)
  end
end

class Rufus::Scheduler::InJob < Rufus::Scheduler::OneTimeJob

  def initialize(scheduler, duration, opts, block)

    super(scheduler, duration, opts, block)

    @next_time =
      @scheduled_at +
      opts[:_t] || Rufus::Scheduler.parse_in(duration, opts)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rufus-scheduler-3.8.2 lib/rufus/scheduler/jobs_one_time.rb
rufus-scheduler-3.8.1 lib/rufus/scheduler/jobs_one_time.rb
rufus-scheduler-3.8.0 lib/rufus/scheduler/jobs_one_time.rb
rufus-scheduler-3.7.0 lib/rufus/scheduler/jobs_one_time.rb