class Inspec::Object::Input
Public Instance Methods
ruby_var_identifier()
click to toggle source
# File lib/inspec/objects/input.rb, line 23 def ruby_var_identifier identifier || "attr_" + name.downcase.strip.gsub(/\s+/, "-").gsub(/[^\w-]/, "") end
to_hash()
click to toggle source
# File lib/inspec/objects/input.rb, line 12 def to_hash as_hash = { name: name, options: {} } %i{description title identifier type required value}.each do |field| val = send(field) next if val.nil? as_hash[:options][field] = val end as_hash end
to_ruby()
click to toggle source
# File lib/inspec/objects/input.rb, line 27 def to_ruby res = ["#{ruby_var_identifier} = attribute('#{name}',{"] res.push " title: '#{title}'," unless title.to_s.empty? res.push " value: #{value.inspect}," unless value.to_s.empty? # to_ruby may generate code that is to be used by older versions of inspec. # Anything older than 3.4 will not recognize the value: option, so # send the default: option as well. See #3759 res.push " default: #{value.inspect}," unless value.to_s.empty? res.push " description: '#{description}'," unless description.to_s.empty? res.push "})" res.join("\n") end