Class: OpenSCAP::Xccdf::Tailoring

Inherits:
Object
  • Object
show all
Defined in:
lib/openscap/xccdf/tailoring.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, benchmark) ⇒ Tailoring

Returns a new instance of Tailoring.



11
12
13
14
15
16
17
18
19
# File 'lib/openscap/xccdf/tailoring.rb', line 11

def initialize(source, benchmark)
  case source
  when OpenSCAP::Source
    @raw = OpenSCAP.xccdf_tailoring_import_source source.raw, benchmark
  else
    raise OpenSCAP::OpenSCAPError, "Cannot initialize #{self.class.name} with '#{source}'"
  end
  OpenSCAP.raise! if @raw.null?
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



9
10
11
# File 'lib/openscap/xccdf/tailoring.rb', line 9

def raw
  @raw
end

Instance Method Details

#destroyObject



30
31
32
33
# File 'lib/openscap/xccdf/tailoring.rb', line 30

def destroy
  OpenSCAP.xccdf_tailoring_free @raw
  @raw = nil
end

#profilesObject



21
22
23
24
25
26
27
28
# File 'lib/openscap/xccdf/tailoring.rb', line 21

def profiles
  @profiles ||= {}.tap do |profiles|
    OpenSCAP._iterate over: OpenSCAP.xccdf_tailoring_get_profiles(@raw), as: 'xccdf_profile' do |pointer|
      profile = OpenSCAP::Xccdf::Profile.new pointer
      profiles[profile.id] = profile
    end
  end
end