Module: PuppetX::Cups::Instances::ClassMembers

Defined in:
lib/puppet_x/cups/instances.rb

Overview

A hash with the names of all classes (as keys) and their members (as array value).

Class Method Summary collapse

Class Method Details

.requestObject


31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/puppet_x/cups/instances.rb', line 31

def self.request
  <<-REQUEST
    {
      OPERATION CUPS-Get-Classes
      GROUP operation
      ATTR charset attributes-charset utf-8
      ATTR language attributes-natural-language en
      DISPLAY printer-name
      DISPLAY member-names
    }
  REQUEST
end

.to_hObject


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puppet_x/cups/instances.rb', line 19

def self.to_h
  classmembers = {}

  query = PuppetX::Cups::Ipp::QueryC.new('/', request)
  query.results.each do |line|
    classname, members = line.split(',', 2)
    classmembers[classname] = members.gsub(/\A"|"\Z/, '').split(',') if members
  end

  classmembers
end