Class: Chemtrail::Declaration

Inherits:
Object
  • Object
show all
Defined in:
lib/chemtrail/declaration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, type, specifications = {}) ⇒ Declaration

Returns a new instance of Declaration.



4
5
6
7
8
# File 'lib/chemtrail/declaration.rb', line 4

def initialize(id, type, specifications = {})
  @id = id
  @type = type
  @specifications = specifications
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'lib/chemtrail/declaration.rb', line 2

def id
  @id
end

#typeObject (readonly)

Returns the value of attribute type.



2
3
4
# File 'lib/chemtrail/declaration.rb', line 2

def type
  @type
end

Instance Method Details

#specificationsObject



10
11
12
# File 'lib/chemtrail/declaration.rb', line 10

def specifications
  @specifications ||= {}
end

#to_hashObject



20
21
22
23
24
25
26
# File 'lib/chemtrail/declaration.rb', line 20

def to_hash
  {
    id => {
      "Type" => type
    }.merge(specifications)
  }
end

#to_referenceObject



14
15
16
17
18
# File 'lib/chemtrail/declaration.rb', line 14

def to_reference
  {
    "Ref" => id
  }
end