Class: Rufus::Scheduler::CronJob

Inherits:
RepeatJob show all
Defined in:
lib/rufus/scheduler/jobs_repeat.rb

Constant Summary

Constants inherited from RepeatJob

RepeatJob::FIRSTS

Constants inherited from Job

Job::EoTime

Instance Attribute Summary collapse

Attributes inherited from RepeatJob

#first_at, #last_at, #paused_at, #times

Attributes inherited from Job

#callable, #count, #handler, #id, #last_time, #last_work_time, #locals, #mean_work_time, #name, #next_time, #opts, #original, #previous_time, #scheduled_at, #tags, #unscheduled_at

Instance Method Summary collapse

Methods inherited from RepeatJob

#determine_id, #next_times, #occurrences, #pause, #paused?, #resume, #trigger

Methods inherited from Job

#[], #[]=, #call, #entries, #has_key?, #keys, #kill, #next_times, #past?, #resume_discard_past=, #running?, #scheduled?, #source_location, #threads, #trigger, #trigger_off_schedule, #unschedule, #values

Constructor Details

#initialize(scheduler, cronline, opts, block) ⇒ CronJob

Returns a new instance of CronJob.



267
268
269
270
271
272
273
274
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 267

def initialize(scheduler, cronline, opts, block)

  super(scheduler, cronline, opts, block)

  @cron_line = opts[:_t] || ::Fugit::Cron.do_parse(cronline)

  set_next_time(nil)
end

Instance Attribute Details

#cron_lineObject (readonly)

Returns the value of attribute cron_line.



265
266
267
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 265

def cron_line
  @cron_line
end

Instance Method Details

#brute_frequencyObject



291
292
293
294
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 291

def brute_frequency

  @cron_line.brute_frequency
end

#check_frequencyObject



276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 276

def check_frequency

  return if @scheduler.frequency <= 1
    #
    # The minimum time delta in a cron job is 1 second, so if the
    # scheduler frequency is less than that, no worries.

  f = @cron_line.rough_frequency

  fail ArgumentError.new(
   "job frequency (min ~#{f}s) is higher than " +
   "scheduler frequency (#{@scheduler.frequency}s)"
  ) if f < @scheduler.frequency
end

#next_time_from(time) ⇒ Object



301
302
303
304
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 301

def next_time_from(time)

  @cron_line.next_time(time)
end

#rough_frequencyObject



296
297
298
299
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 296

def rough_frequency

  @cron_line.rough_frequency
end