Class: PuppetX::Relay::Agent::Job::Schedule
- Inherits:
-
Object
- Object
- PuppetX::Relay::Agent::Job::Schedule
- Defined in:
- lib/puppet_x/relay/agent/job/schedule.rb
Instance Attribute Summary collapse
- #first_run_at ⇒ Time readonly
- #interval ⇒ Integer readonly
- #last_run_at ⇒ Time readonly
Class Method Summary collapse
Instance Method Summary collapse
- #elapsed ⇒ Integer
-
#initialize(interval, first_run_at: nil, last_run_at: nil) ⇒ Schedule
constructor
A new instance of Schedule.
- #next_run_at ⇒ Time
- #next_update_before ⇒ Time
Constructor Details
#initialize(interval, first_run_at: nil, last_run_at: nil) ⇒ Schedule
Returns a new instance of Schedule.
22 23 24 25 26 |
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 22 def initialize(interval, first_run_at: nil, last_run_at: nil) @interval = interval @first_run_at = first_run_at || Time.now @last_run_at = last_run_at || @first_run_at end |
Instance Attribute Details
#first_run_at ⇒ Time (readonly)
20 21 22 |
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 20 def first_run_at @first_run_at end |
#interval ⇒ Integer (readonly)
17 18 19 |
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 17 def interval @interval end |
#last_run_at ⇒ Time (readonly)
20 21 22 |
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 20 def last_run_at @last_run_at end |
Class Method Details
.from_scheduler_job(job) ⇒ Object
11 12 13 |
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 11 def from_scheduler_job(job) new(job.run_interval, first_run_at: job.start_time, last_run_at: job.last_run) end |
Instance Method Details
#elapsed ⇒ Integer
39 40 41 |
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 39 def elapsed last_run_at - first_run_at end |
#next_run_at ⇒ Time
29 30 31 |
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 29 def next_run_at last_run_at + interval end |
#next_update_before ⇒ Time
34 35 36 |
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 34 def next_update_before last_run_at + interval * 3 end |