Class: Chemtrail::Resource
- Inherits:
-
Object
- Object
- Chemtrail::Resource
- Defined in:
- lib/chemtrail/resource.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(id, type) ⇒ Resource
constructor
A new instance of Resource.
- #properties ⇒ Object
- #to_hash ⇒ Object
- #to_reference ⇒ Object
Constructor Details
#initialize(id, type) ⇒ Resource
Returns a new instance of Resource.
4 5 6 7 |
# File 'lib/chemtrail/resource.rb', line 4 def initialize(id, type) @id = id @type = type end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
2 3 4 |
# File 'lib/chemtrail/resource.rb', line 2 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
2 3 4 |
# File 'lib/chemtrail/resource.rb', line 2 def type @type end |
Instance Method Details
#properties ⇒ Object
13 14 15 |
# File 'lib/chemtrail/resource.rb', line 13 def properties @properties ||= Chemtrail::PropertyList.new end |
#to_hash ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/chemtrail/resource.rb', line 17 def to_hash { id => { "Type" => type, "Properties" => properties.to_hash } } end |
#to_reference ⇒ Object
9 10 11 |
# File 'lib/chemtrail/resource.rb', line 9 def to_reference { "Ref" => id } end |