Method: Inspec::Control#to_ruby

Defined in:
lib/inspec/objects/control.rb

#to_rubyObject

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?
  tags.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