Class: Helium::Label
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Resource
Instance Method Summary collapse
- #add_sensors(sensors_to_add = []) ⇒ Object
-
#as_json ⇒ Object
TODO can probably generalize this a bit more.
- #destroy ⇒ Object
-
#initialize(client:, params:) ⇒ Label
constructor
A new instance of Label.
- #remove_sensors(sensors_to_remove = []) ⇒ Object
-
#sensors ⇒ Object
TODO: would be nice to wrap this in a proxy collection, that way we could do something like label.sensors << new_sensor.
- #update(name:) ⇒ Object
Methods inherited from Resource
#==, #created_at, #eql?, #hash, #to_json, #updated_at
Constructor Details
#initialize(client:, params:) ⇒ Label
Returns a new instance of Label
5 6 7 8 9 |
# File 'lib/helium/label.rb', line 5 def initialize(client:, params:) super(client: client, params: params) @name = params.dig("attributes", "name") end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name
3 4 5 |
# File 'lib/helium/label.rb', line 3 def name @name end |
Instance Method Details
#add_sensors(sensors_to_add = []) ⇒ Object
25 26 27 28 29 |
# File 'lib/helium/label.rb', line 25 def add_sensors(sensors_to_add = []) sensors_to_add = Array(sensors_to_add) @client.update_label_sensors(self, sensors: sensors + sensors_to_add) end |
#as_json ⇒ Object
TODO can probably generalize this a bit more
38 39 40 41 42 |
# File 'lib/helium/label.rb', line 38 def as_json super.merge({ name: name }) end |
#destroy ⇒ Object
15 16 17 |
# File 'lib/helium/label.rb', line 15 def destroy @client.delete_label(self) end |
#remove_sensors(sensors_to_remove = []) ⇒ Object
31 32 33 34 35 |
# File 'lib/helium/label.rb', line 31 def remove_sensors(sensors_to_remove = []) sensors_to_remove = Array(sensors_to_remove) @client.update_label_sensors(self, sensors: sensors - sensors_to_remove) end |
#sensors ⇒ Object
TODO: would be nice to wrap this in a proxy collection, that way we could do something like label.sensors << new_sensor
21 22 23 |
# File 'lib/helium/label.rb', line 21 def sensors @client.label_sensors(self) end |
#update(name:) ⇒ Object
11 12 13 |
# File 'lib/helium/label.rb', line 11 def update(name:) @client.update_label(self, name: name) end |