Class: ChefCLI::Policyfile::PolicyGroupRevIDMap

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/chef-cli/policyfile/lister.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (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_groupObject (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

#eachObject



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

Returns:

  • (Boolean)


98
99
100
# File 'lib/chef-cli/policyfile/lister.rb', line 98

def empty?
  policy_group_names.empty?
end

#format_revision_idsObject



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_lengthObject



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_namesObject



83
84
85
# File 'lib/chef-cli/policyfile/lister.rb', line 83

def policy_group_names
  revision_ids_by_group.keys
end

#unique_revision_idsObject



79
80
81
# File 'lib/chef-cli/policyfile/lister.rb', line 79

def unique_revision_ids
  revision_ids_by_group.values.uniq
end