Class: PuppetX::Relay::Agent::Job::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/relay/agent/job/schedule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_atTime (readonly)

Returns:

  • (Time)


20
21
22
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 20

def first_run_at
  @first_run_at
end

#intervalInteger (readonly)

Returns:

  • (Integer)


17
18
19
# File 'lib/puppet_x/relay/agent/job/schedule.rb', line 17

def interval
  @interval
end

#last_run_atTime (readonly)

Returns:

  • (Time)


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

Parameters:

  • job (Puppet::Scheduler::Job)


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

#elapsedInteger

Returns:

  • (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_atTime

Returns:

  • (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_beforeTime

Returns:

  • (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