Class: ChefAB::TimeLinearUpgrader
- Inherits:
-
BaseUpgrader
- Object
- BaseUpgrader
- ChefAB::TimeLinearUpgrader
- Defined in:
- lib/chef-ab/time_linear_upgrader.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Attributes inherited from BaseUpgrader
Instance Method Summary collapse
- #expected_activation ⇒ Object
-
#initialize(options) ⇒ TimeLinearUpgrader
constructor
A new instance of TimeLinearUpgrader.
- #should_execute?(time = nil) ⇒ Boolean
Methods inherited from BaseUpgrader
Constructor Details
#initialize(options) ⇒ TimeLinearUpgrader
Returns a new instance of TimeLinearUpgrader.
8 9 10 11 12 13 14 |
# File 'lib/chef-ab/time_linear_upgrader.rb', line 8 def initialize() super() @start_time = [:start_time].to_i @end_time = [:end_time].to_i upgrade_span = @end_time - @start_time @hash = @hash % upgrade_span end |
Instance Attribute Details
#end_time ⇒ Object
Returns the value of attribute end_time.
6 7 8 |
# File 'lib/chef-ab/time_linear_upgrader.rb', line 6 def end_time @end_time end |
#start_time ⇒ Object
Returns the value of attribute start_time.
6 7 8 |
# File 'lib/chef-ab/time_linear_upgrader.rb', line 6 def start_time @start_time end |
Instance Method Details
#expected_activation ⇒ Object
22 23 24 25 26 |
# File 'lib/chef-ab/time_linear_upgrader.rb', line 22 def expected_activation (@start_time..@end_time).to_a.bsearch do |fake_time| should_execute?(fake_time) end end |
#should_execute?(time = nil) ⇒ Boolean
16 17 18 19 20 |
# File 'lib/chef-ab/time_linear_upgrader.rb', line 16 def should_execute?(time = nil) time ||= current_time threshold = time - start_time super(threshold) end |