Class: Rufus::Scheduler::EveryJob

Inherits:
EvInJob 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 EvInJob

#first_at=

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?, #running?, #scheduled?, #source_location, #threads, #trigger, #trigger_off_schedule, #unschedule, #values

Constructor Details

#initialize(scheduler, duration, opts, block) ⇒ EveryJob

Returns a new instance of EveryJob.



169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 169

def initialize(scheduler, duration, opts, block)

  super(scheduler, duration, opts, block)

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

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

  set_next_time(nil)
end

Instance Attribute Details

#frequencyObject (readonly)

Returns the value of attribute frequency.



165
166
167
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 165

def frequency
  @frequency
end

#resume_discard_pastObject

Returns the value of attribute resume_discard_past.



167
168
169
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 167

def resume_discard_past
  @resume_discard_past
end

Instance Method Details

#check_frequencyObject



183
184
185
186
187
188
189
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 183

def check_frequency

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

#next_time_from(time) ⇒ Object



191
192
193
194
# File 'lib/rufus/scheduler/jobs_repeat.rb', line 191

def next_time_from(time)

  time + @frequency
end