Class: Puppet::Scheduler::Job Private
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Attribute Summary collapse
- #last_run ⇒ Object private
- #run_interval ⇒ Object private
- #start_time ⇒ Object private
Instance Method Summary collapse
- #disable ⇒ Object private
- #enable ⇒ Object private
- #enabled? ⇒ Boolean private
-
#initialize(run_interval, &block) ⇒ Job
constructor
private
A new instance of Job.
- #interval_to_next_from(time) ⇒ Object private
- #ready?(time) ⇒ Boolean private
- #run(now) ⇒ Object private
Constructor Details
#initialize(run_interval, &block) ⇒ Job
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Job.
8 9 10 11 12 13 |
# File 'lib/puppet/scheduler/job.rb', line 8 def initialize(run_interval, &block) self.run_interval = run_interval @last_run = nil @run_proc = block @enabled = true end |
Instance Attribute Details
#last_run ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/puppet/scheduler/job.rb', line 5 def last_run @last_run end |
#run_interval ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
4 5 6 |
# File 'lib/puppet/scheduler/job.rb', line 4 def run_interval @run_interval end |
#start_time ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/puppet/scheduler/job.rb', line 6 def start_time @start_time end |
Instance Method Details
#disable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 |
# File 'lib/puppet/scheduler/job.rb', line 35 def disable @enabled = false end |
#enable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/puppet/scheduler/job.rb', line 31 def enable @enabled = true end |
#enabled? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/puppet/scheduler/job.rb', line 27 def enabled? @enabled end |
#interval_to_next_from(time) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 42 43 44 45 |
# File 'lib/puppet/scheduler/job.rb', line 39 def interval_to_next_from(time) if ready?(time) 0 else @run_interval - (time - @last_run) end end |
#ready?(time) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 25 |
# File 'lib/puppet/scheduler/job.rb', line 19 def ready?(time) if @last_run @last_run + @run_interval <= time else true end end |
#run(now) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 52 |
# File 'lib/puppet/scheduler/job.rb', line 47 def run(now) @last_run = now if @run_proc @run_proc.call(self) end end |