Class: ChefCLI::Policyfile::PolicyGroupRevIDMap
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::PolicyGroupRevIDMap
- Includes:
- Enumerable
- Defined in:
- lib/chef-cli/policyfile/lister.rb
Instance Attribute Summary collapse
-
#policy_name ⇒ Object
readonly
Returns the value of attribute policy_name.
-
#revision_ids_by_group ⇒ Object
readonly
Returns the value of attribute revision_ids_by_group.
Instance Method Summary collapse
- #each ⇒ Object
- #empty? ⇒ Boolean
- #format_revision_ids ⇒ Object
-
#initialize(policy_name, revision_ids_by_group) ⇒ PolicyGroupRevIDMap
constructor
A new instance of PolicyGroupRevIDMap.
- #max_group_name_length ⇒ Object
- #policy_group_names ⇒ Object
- #unique_revision_ids ⇒ Object
Constructor Details
#initialize(policy_name, revision_ids_by_group) ⇒ PolicyGroupRevIDMap
Returns a new instance of PolicyGroupRevIDMap.
74 75 76 77 |
# File 'lib/chef-cli/policyfile/lister.rb', line 74 def initialize(policy_name, revision_ids_by_group) @policy_name = policy_name @revision_ids_by_group = revision_ids_by_group end |
Instance Attribute Details
#policy_name ⇒ Object (readonly)
Returns the value of attribute policy_name.
71 72 73 |
# File 'lib/chef-cli/policyfile/lister.rb', line 71 def policy_name @policy_name end |
#revision_ids_by_group ⇒ Object (readonly)
Returns the value of attribute revision_ids_by_group.
72 73 74 |
# File 'lib/chef-cli/policyfile/lister.rb', line 72 def revision_ids_by_group @revision_ids_by_group end |
Instance Method Details
#each ⇒ Object
102 103 104 105 106 |
# File 'lib/chef-cli/policyfile/lister.rb', line 102 def each revision_ids_by_group.each do |group_name, rev_id| yield group_name, rev_id end end |
#empty? ⇒ Boolean
98 99 100 |
# File 'lib/chef-cli/policyfile/lister.rb', line 98 def empty? policy_group_names.empty? end |
#format_revision_ids ⇒ Object
91 92 93 94 95 96 |
# File 'lib/chef-cli/policyfile/lister.rb', line 91 def format_revision_ids revision_ids_by_group.inject({}) do |map, (group_name, rev_id)| map[group_name] = yield rev_id map end end |
#max_group_name_length ⇒ Object
87 88 89 |
# File 'lib/chef-cli/policyfile/lister.rb', line 87 def max_group_name_length policy_group_names.map(&:size).max end |
#policy_group_names ⇒ Object
83 84 85 |
# File 'lib/chef-cli/policyfile/lister.rb', line 83 def policy_group_names revision_ids_by_group.keys end |
#unique_revision_ids ⇒ Object
79 80 81 |
# File 'lib/chef-cli/policyfile/lister.rb', line 79 def unique_revision_ids revision_ids_by_group.values.uniq end |