Class: Moon::Scheduler::Jobs::Interval

Inherits:
TimeBase show all
Defined in:
lib/moon/packages/scheduler/jobs/interval.rb

Overview

Invertals are forever running jobs, they will execute their callback after the duration has ended, and then restart, which is similar behavior to a Timeout.

Instance Attribute Summary

Attributes inherited from TimeBase

#duration, #time

Attributes inherited from Base

#active, #id, #key, #killed, #uptime

Instance Method Summary collapse

Methods inherited from TimeBase

#initialize, #rate, #restart, #stop, #timeout?, #update_job, #update_job_step

Methods inherited from Base

#initialize, #kill, #killed?, #trigger_callback, #update, #update_job

Methods included from Activatable

#activate, #active?, #deactivate

Methods included from Eventable

#allow_event?, #clear_events, #each_listener, #each_typed_listener, filter_from_options, #has_events?, #initialize_eventable, #off, #on, #ppd_ev, #trigger, #typing

Constructor Details

This class inherits a constructor from Moon::Scheduler::Jobs::TimeBase

Instance Method Details

#done?Boolean

Returns:


11
12
13
# File 'lib/moon/packages/scheduler/jobs/interval.rb', line 11

def done?
  killed?
end

#finishObject

Force end the interval, intervals can't “finish”


26
27
28
# File 'lib/moon/packages/scheduler/jobs/interval.rb', line 26

def finish  #

end

#on_timeoutObject

When time reaches 0 or less


16
17
18
19
20
21
22
23
# File 'lib/moon/packages/scheduler/jobs/interval.rb', line 16

def on_timeout  # since its possible that the timestep will be too large, it needs
  # to re-trigger the callback until the @time is greater than 0

  until @time > 0
    trigger_callback
    restart
  end
end