Class: Inspec::Control
- Inherits:
-
Object
- Object
- Inspec::Control
- Defined in:
- lib/inspec/objects/control.rb
Instance Attribute Summary collapse
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#id ⇒ Object
Returns the value of attribute id.
-
#impact ⇒ Object
Returns the value of attribute impact.
-
#refs ⇒ Object
Returns the value of attribute refs.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#tests ⇒ Object
Returns the value of attribute tests.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #add_tag(t) ⇒ Object
- #add_test(t) ⇒ Object
-
#initialize ⇒ Control
constructor
A new instance of Control.
- #to_hash ⇒ Object
-
#to_ruby ⇒ Object
rubocop:disable Metrics/AbcSize.
Constructor Details
#initialize ⇒ Control
Returns a new instance of Control.
6 7 8 9 10 |
# File 'lib/inspec/objects/control.rb', line 6 def initialize @tests = [] @tags = [] @refs = [] end |
Instance Attribute Details
#desc ⇒ Object
Returns the value of attribute desc.
5 6 7 |
# File 'lib/inspec/objects/control.rb', line 5 def desc @desc end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/inspec/objects/control.rb', line 5 def id @id end |
#impact ⇒ Object
Returns the value of attribute impact.
5 6 7 |
# File 'lib/inspec/objects/control.rb', line 5 def impact @impact end |
#refs ⇒ Object
Returns the value of attribute refs.
5 6 7 |
# File 'lib/inspec/objects/control.rb', line 5 def refs @refs end |
#tags ⇒ Object
Returns the value of attribute tags.
5 6 7 |
# File 'lib/inspec/objects/control.rb', line 5 def @tags end |
#tests ⇒ Object
Returns the value of attribute tests.
5 6 7 |
# File 'lib/inspec/objects/control.rb', line 5 def tests @tests end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/inspec/objects/control.rb', line 5 def title @title end |
Instance Method Details
#add_tag(t) ⇒ Object
16 17 18 |
# File 'lib/inspec/objects/control.rb', line 16 def add_tag(t) @tags.push(t) end |
#add_test(t) ⇒ Object
12 13 14 |
# File 'lib/inspec/objects/control.rb', line 12 def add_test(t) @tests.push(t) end |
#to_hash ⇒ Object
20 21 22 |
# File 'lib/inspec/objects/control.rb', line 20 def to_hash { id: id, title: title, desc: desc, impact: impact, tests: tests.map(&:to_hash), tags: .map(&:to_hash) } end |
#to_ruby ⇒ Object
rubocop:disable Metrics/AbcSize
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/inspec/objects/control.rb', line 24 def to_ruby # rubocop:disable Metrics/AbcSize res = ["control #{id.inspect} do"] res.push " title #{title.inspect}" unless title.to_s.empty? res.push " desc #{prettyprint_text(desc, 2)}" unless desc.to_s.empty? res.push " impact #{impact}" unless impact.nil? .each { |t| res.push(indent(t.to_ruby, 2)) } refs.each { |t| res.push(" ref #{print_ref(t)}") } tests.each { |t| res.push(indent(t.to_ruby, 2)) } res.push 'end' res.join("\n") end |