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.
-
#initialize(opts = {}) ⇒ 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.
Methods inherited from Resource
#==, all, create, #created_at, #destroy, #eql?, find, #hash, #to_json, #update, #updated_at
Constructor Details
#initialize(opts = {}) ⇒ Label
Returns a new instance of Label
5 6 7 8 9 |
# File 'lib/helium/label.rb', line 5 def initialize(opts = {}) super(opts) @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
17 18 19 20 21 |
# File 'lib/helium/label.rb', line 17 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
30 31 32 33 34 |
# File 'lib/helium/label.rb', line 30 def as_json super.merge({ name: name }) end |
#remove_sensors(sensors_to_remove = []) ⇒ Object
23 24 25 26 27 |
# File 'lib/helium/label.rb', line 23 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
13 14 15 |
# File 'lib/helium/label.rb', line 13 def sensors @client.label_sensors(self) end |