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.



19
20
21
22
23
24
25
26
27
# File 'lib/openscap/ds/sds.rb', line 19

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?
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



17
18
19
# File 'lib/openscap/ds/sds.rb', line 17

def raw
  @raw
end

Instance Method Details

#destroyObject



46
47
48
49
# File 'lib/openscap/ds/sds.rb', line 46

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

#html_guide(profile = nil) ⇒ Object



40
41
42
43
44
# File 'lib/openscap/ds/sds.rb', line 40

def html_guide(profile = nil)
  html = OpenSCAP.ds_sds_session_get_html_guide(@raw, profile)
  OpenSCAP.raise! if html.nil?
  html
end

#select_checklist(p = {}) ⇒ Object



29
30
31
32
# File 'lib/openscap/ds/sds.rb', line 29

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



34
35
36
37
38
# File 'lib/openscap/ds/sds.rb', line 34

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