Class: OpenSCAP::Xccdf::TestResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(t) ⇒ TestResult

Returns a new instance of TestResult.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/openscap/xccdf/testresult.rb', line 14

def initialize(t)
  case t
  when OpenSCAP::Source
    @raw = OpenSCAP.xccdf_result_import_source(t.raw)
    OpenSCAP.raise! if @raw.null?
  when FFI::Pointer
    @raw = OpenSCAP.xccdf_result_import_source(t)
    OpenSCAP.raise! if @raw.null?
  else
    raise OpenSCAP::OpenSCAPError, "Cannot initialize #{self.class.name} with #{t}"
  end
  init_ruleresults
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



12
13
14
# File 'lib/openscap/xccdf/testresult.rb', line 12

def raw
  @raw
end

#rrObject (readonly)

Returns the value of attribute rr.



11
12
13
# File 'lib/openscap/xccdf/testresult.rb', line 11

def rr
  @rr
end

Instance Method Details

#destroyObject



52
53
54
55
# File 'lib/openscap/xccdf/testresult.rb', line 52

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

#idObject



28
29
30
# File 'lib/openscap/xccdf/testresult.rb', line 28

def id
  OpenSCAP.xccdf_result_get_id(@raw)
end

#profileObject



32
33
34
# File 'lib/openscap/xccdf/testresult.rb', line 32

def profile
  OpenSCAP.xccdf_result_get_profile(@raw)
end

#scoreObject



36
37
38
# File 'lib/openscap/xccdf/testresult.rb', line 36

def score
  @score ||= score_init
end

#score!(benchmark) ⇒ Object



40
41
42
43
44
45
# File 'lib/openscap/xccdf/testresult.rb', line 40

def score!(benchmark)
  # recalculate the scores in the scope of given benchmark
  @score = nil
  OpenSCAP.raise! unless OpenSCAP.xccdf_result_recalculate_scores(@raw, benchmark.raw).zero?
  score
end

#sourceObject



47
48
49
50
# File 'lib/openscap/xccdf/testresult.rb', line 47

def source
  source_p = OpenSCAP.xccdf_result_export_source(raw, nil)
  OpenSCAP::Source.new source_p
end