class Inspec::Object::EachLoop

Attributes

tests[RW]
variables[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/inspec/objects/each_loop.rb, line 7
def initialize
  super
  @tests = []
  @variables = []
end

Public Instance Methods

add_test(t = nil) click to toggle source
# File lib/inspec/objects/each_loop.rb, line 13
def add_test(t = nil)
  t ||= Test.new
  t.qualifier[0] = ["entry"]
  @tests.push(t)
  t
end
negate!() click to toggle source
# File lib/inspec/objects/each_loop.rb, line 20
def negate!
  @tests.each(&:negate!)
end
to_hash() click to toggle source
# File lib/inspec/objects/each_loop.rb, line 24
def to_hash
  { qualifier: qualifier, test: @test }
end
to_ruby() click to toggle source
Calls superclass method
# File lib/inspec/objects/each_loop.rb, line 28
def to_ruby
  vars = variables.map(&:to_ruby).join("\n")
  vars += "\n" unless vars.empty?
  obj = super
  all_tests = @tests.map(&:to_ruby).join("\n").gsub("\n", "\n  ")
  format("%s%s.each do |entry|\n  %s\nend", vars, obj, all_tests)
end