class Inspec::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 10 def initialize super @tests = [] @variables = [] Inspec.deprecate(:object_classes, "The Inspec::EachLoop class is deprecated. Use the Inspec::Object::EachLoop class from the inspec-objects Ruby library.") end
Public Instance Methods
add_test(t = nil)
click to toggle source
# File lib/inspec/objects/each_loop.rb, line 18 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 25 def negate! @tests.each(&:negate!) end
to_hash()
click to toggle source
# File lib/inspec/objects/each_loop.rb, line 29 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 33 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