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, properties = nil) ⇒ Resource
constructor
A new instance of Resource.
- #properties ⇒ Object
- #to_hash ⇒ Object
- #to_reference ⇒ Object
Constructor Details
#initialize(id, type, properties = nil) ⇒ Resource
Returns a new instance of Resource.
4 5 6 7 8 |
# File 'lib/chemtrail/resource.rb', line 4 def initialize(id, type, properties = nil) @id = id @type = type @properties = Chemtrail::PropertyList.new.merge(properties) if properties 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
14 15 16 |
# File 'lib/chemtrail/resource.rb', line 14 def properties @properties ||= Chemtrail::PropertyList.new end |
#to_hash ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/chemtrail/resource.rb', line 18 def to_hash { id => { "Type" => type, "Properties" => properties.to_hash } } end |
#to_reference ⇒ Object
10 11 12 |
# File 'lib/chemtrail/resource.rb', line 10 def to_reference { "Ref" => id } end |