Recurring job with a certain frequency.
The frequency, in seconds, of this EveryJob
# File lib/rufus/sc/jobs.rb, line 347 def initialize(scheduler, t, params, &block) super determine_frequency determine_at end
Triggers the job (and reschedules it).
# File lib/rufus/sc/jobs.rb, line 357 def trigger schedule_next super end
# File lib/rufus/sc/jobs.rb, line 375 def determine_at return unless @frequency @last = @at # the first time, @last will be nil now = Time.now.to_f @at = if @last @last + @frequency else if fi = @params[:first_in] now + Rufus.duration_to_f(fi) elsif fa = @params[:first_at] Rufus.at_to_f(fa) else now + @frequency end end while @at < now do @at += @frequency end if @params[:discard_past] end
# File lib/rufus/sc/jobs.rb, line 366 def determine_frequency @frequency = if @t.is_a?(Fixnum) || @t.is_a?(Float) @t else Rufus.parse_duration_string(@t) end end
It’s an every job, have to schedule next time it occurs…
# File lib/rufus/sc/jobs.rb, line 403 def schedule_next determine_at @scheduler.send(:add_job, self) end