Class: Inspec::Attribute
- Inherits:
-
Object
- Object
- Inspec::Attribute
- Defined in:
- lib/inspec/objects/attribute.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #default ⇒ Object
-
#initialize(name, options) ⇒ Attribute
constructor
A new instance of Attribute.
- #to_hash ⇒ Object
- #to_s ⇒ Object
-
#value(newvalue = nil) ⇒ Object
implicit call is done by inspec to determine the value of an attribute.
Constructor Details
#initialize(name, options) ⇒ Attribute
Returns a new instance of Attribute.
6 7 8 9 10 |
# File 'lib/inspec/objects/attribute.rb', line 6 def initialize(name, ) @name = name @opts = @value = nil end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/inspec/objects/attribute.rb', line 5 def name @name end |
Instance Method Details
#default ⇒ Object
20 21 22 |
# File 'lib/inspec/objects/attribute.rb', line 20 def default @opts[:default] end |
#to_hash ⇒ Object
24 25 26 27 28 29 |
# File 'lib/inspec/objects/attribute.rb', line 24 def to_hash { name: @name, options: @opts, } end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/inspec/objects/attribute.rb', line 31 def to_s "Attribute #{@name} with #{@value}" end |
#value(newvalue = nil) ⇒ Object
implicit call is done by inspec to determine the value of an attribute
13 14 15 16 17 18 |
# File 'lib/inspec/objects/attribute.rb', line 13 def value(newvalue = nil) unless newvalue.nil? @value = newvalue end @value || default end |