Class: Inspec::RunData::Control

Inherits:
Struct
  • Object
show all
Includes:
HashLikeStruct
Defined in:
lib/inspec/run_data/control.rb,
lib/inspec/run_data/control.rb

Defined Under Namespace

Classes: Ref, SourceLocation, WaiverData

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashLikeStruct

#key?, #keys, #non_nil?

Constructor Details

#initialize(raw_ctl_data) ⇒ Control

Returns a new instance of Control.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/inspec/run_data/control.rb', line 19

def initialize(raw_ctl_data)
  self.refs = (raw_ctl_data[:refs] || []).map { |r| Inspec::RunData::Control::Ref.new(r) }
  self.results = (raw_ctl_data[:results] || []).map { |r| Inspec::RunData::Result.new(r) }
  self.source_location = Inspec::RunData::Control::SourceLocation.new(raw_ctl_data[:source_location] || {})
  self.waiver_data = Inspec::RunData::Control::WaiverData.new(raw_ctl_data[:waiver_data] || {})

  [
    :code,            # String
    :desc,            # String
    :descriptions,    # Hash with custom keys
    :id,              # String
    :impact,          # Float
    :tags,            # Hash with custom keys
    :title,           # String
  ].each do |field|
    self[field] = raw_ctl_data[field]
  end

  def status
    Inspec::EnhancedOutcomes.determine_status(results, impact)
  end
end

Instance Attribute Details

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def code
  @code
end

#descObject

Returns the value of attribute desc

Returns:

  • (Object)

    the current value of desc



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def desc
  @desc
end

#descriptionsObject

Returns the value of attribute descriptions

Returns:

  • (Object)

    the current value of descriptions



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def descriptions
  @descriptions
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def id
  @id
end

#impactObject

Returns the value of attribute impact

Returns:

  • (Object)

    the current value of impact



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def impact
  @impact
end

#refsObject

Returns the value of attribute refs

Returns:

  • (Object)

    the current value of refs



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def refs
  @refs
end

#resultsObject

Returns the value of attribute results

Returns:

  • (Object)

    the current value of results



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def results
  @results
end

#source_locationObject

Returns the value of attribute source_location

Returns:

  • (Object)

    the current value of source_location



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def source_location
  @source_location
end

#tagsObject

Returns the value of attribute tags

Returns:

  • (Object)

    the current value of tags



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def tags
  @tags
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def title
  @title
end

#waiver_dataObject

Returns the value of attribute waiver_data

Returns:

  • (Object)

    the current value of waiver_data



5
6
7
# File 'lib/inspec/run_data/control.rb', line 5

def waiver_data
  @waiver_data
end

Instance Method Details

#statusObject



37
38
39
# File 'lib/inspec/run_data/control.rb', line 37

def status
  Inspec::EnhancedOutcomes.determine_status(results, impact)
end