Class: OpenSCAP::DS::Sds

Inherits:
Object
  • Object
show all
Defined in:
lib/openscap/ds/sds.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param) ⇒ Sds

Returns a new instance of Sds.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/openscap/ds/sds.rb', line 10

def initialize(param)
  @raw = case param
         when OpenSCAP::Source
           OpenSCAP.ds_sds_session_new_from_source param.raw
         when Hash
           OpenSCAP.ds_sds_session_new_from_source param[:source].raw
         end
  OpenSCAP.raise! if @raw.null?

  begin
    yield self
  ensure
    destroy
  end if block_given?
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



8
9
10
# File 'lib/openscap/ds/sds.rb', line 8

def raw
  @raw
end

Instance Method Details

#destroyObject



37
38
39
40
# File 'lib/openscap/ds/sds.rb', line 37

def destroy
  OpenSCAP.ds_sds_session_free(@raw)
  @raw = nil
end

#select_checklist(p = {}) ⇒ Object



26
27
28
29
# File 'lib/openscap/ds/sds.rb', line 26

def select_checklist(p = {})
  source_p = OpenSCAP.ds_sds_session_select_checklist(@raw, p[:datastream_id], p[:component_id], nil)
  OpenSCAP::Source.new source_p
end

#select_checklist!(p = {}) ⇒ Object



31
32
33
34
35
# File 'lib/openscap/ds/sds.rb', line 31

def select_checklist!(p = {})
  checklist = select_checklist(p)
  OpenSCAP.raise! if checklist.nil? or checklist.raw.null?
  checklist
end