Class: ChefAB::BaseUpgrader
- Inherits:
-
Object
- Object
- ChefAB::BaseUpgrader
- Defined in:
- lib/chef-ab/base_upgrader.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#node_id ⇒ Object
Returns the value of attribute node_id.
Instance Method Summary collapse
- #execute(&block) ⇒ Object
-
#initialize(node_id) ⇒ BaseUpgrader
constructor
A new instance of BaseUpgrader.
- #should_execute?(threshold) ⇒ Boolean
Constructor Details
#initialize(node_id) ⇒ BaseUpgrader
7 8 9 10 11 12 13 14 |
# File 'lib/chef-ab/base_upgrader.rb', line 7 def initialize(node_id) @node_id = node_id if node_id.is_a? Integer @hash = node_id else @hash = Zlib.crc32 (node_id.to_s) end end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
5 6 7 |
# File 'lib/chef-ab/base_upgrader.rb', line 5 def hash @hash end |
#node_id ⇒ Object
Returns the value of attribute node_id.
5 6 7 |
# File 'lib/chef-ab/base_upgrader.rb', line 5 def node_id @node_id end |
Instance Method Details
#execute(&block) ⇒ Object
20 21 22 23 24 |
# File 'lib/chef-ab/base_upgrader.rb', line 20 def execute(&block) if block_given? && should_execute? block.call end end |
#should_execute?(threshold) ⇒ Boolean
16 17 18 |
# File 'lib/chef-ab/base_upgrader.rb', line 16 def should_execute?(threshold) @hash < threshold end |