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(client:, params:) ⇒ Element
constructor
A new instance of Element.
-
#update(name:) ⇒ Object
TODO these kinds of methods should be generalized into a Resource object.
Methods inherited from Resource
#==, #created_at, #eql?, #hash, #to_json, #updated_at
Constructor Details
#initialize(client:, params:) ⇒ Element
Returns a new instance of Element
5 6 7 8 9 10 11 |
# File 'lib/helium/element.rb', line 5 def initialize(client:, params:) super(client: client, params: params) @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
19 20 21 22 23 24 25 |
# File 'lib/helium/element.rb', line 19 def as_json super.merge({ name: name, mac: mac, versions: versions }) end |
#update(name:) ⇒ Object
TODO these kinds of methods should be generalized into a Resource object
14 15 16 |
# File 'lib/helium/element.rb', line 14 def update(name:) @client.update_element(self, name: name) end |