Class: Helium::Element
Instance Attribute Summary collapse
-
#mac ⇒ Object
readonly
Returns the value of attribute mac.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#versions ⇒ Object
readonly
Returns the value of attribute versions.
Attributes inherited from Resource
Instance Method Summary collapse
-
#as_json ⇒ Object
TODO can probably generalize this a bit more.
-
#initialize(opts = {}) ⇒ Element
constructor
A new instance of Element.
- #sensors ⇒ Object
Methods inherited from Resource
#==, all, create, #created_at, #destroy, #eql?, find, #hash, #to_json, #update, #updated_at
Constructor Details
#initialize(opts = {}) ⇒ Element
Returns a new instance of Element
5 6 7 8 9 10 11 |
# File 'lib/helium/element.rb', line 5 def initialize(opts = {}) super(opts) @name = @params.dig("attributes", "name") @mac = @params.dig("meta", "mac") @versions = @params.dig("meta", "versions") end |
Instance Attribute Details
#mac ⇒ Object (readonly)
Returns the value of attribute mac
3 4 5 |
# File 'lib/helium/element.rb', line 3 def mac @mac end |
#name ⇒ Object (readonly)
Returns the value of attribute name
3 4 5 |
# File 'lib/helium/element.rb', line 3 def name @name end |
#versions ⇒ Object (readonly)
Returns the value of attribute versions
3 4 5 |
# File 'lib/helium/element.rb', line 3 def versions @versions end |
Instance Method Details
#as_json ⇒ Object
TODO can probably generalize this a bit more
18 19 20 21 22 23 24 |
# File 'lib/helium/element.rb', line 18 def as_json super.merge({ name: name, mac: mac, versions: versions }) end |
#sensors ⇒ Object
13 14 15 |
# File 'lib/helium/element.rb', line 13 def sensors @client.element_sensors(self) end |