Class: Inspec::Object::Value

Inherits:
Object
  • Object
show all
Includes:
RubyHelper
Defined in:
lib/inspec/objects/value.rb

Direct Known Subclasses

List

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RubyHelper

#ruby_qualifier

Constructor Details

#initialize(qualifiers = []) ⇒ Value

Returns a new instance of Value.



9
10
11
12
# File 'lib/inspec/objects/value.rb', line 9

def initialize(qualifiers = [])
  @qualifier = qualifiers
  @variable = nil
end

Instance Attribute Details

#qualifierObject

Returns the value of attribute qualifier.



5
6
7
# File 'lib/inspec/objects/value.rb', line 5

def qualifier
  @qualifier
end

#skipObject

Returns the value of attribute skip.



6
7
8
# File 'lib/inspec/objects/value.rb', line 6

def skip
  @skip
end

#variableObject

Returns the value of attribute variable.



7
8
9
# File 'lib/inspec/objects/value.rb', line 7

def variable
  @variable
end

Instance Method Details

#name_variable(cache = []) ⇒ Object



19
20
21
22
23
# File 'lib/inspec/objects/value.rb', line 19

def name_variable(cache = [])
  @variable = Array("a".."z").find { |x| !cache.include?(x) }
  cache.push(@variable)
  @variable
end

#to_rubyObject



14
15
16
17
# File 'lib/inspec/objects/value.rb', line 14

def to_ruby
  res = @variable.nil? ? "" : "#{@variable} = "
  res + @qualifier.map { |x| ruby_qualifier(x) }.join(".")
end