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
Methods inherited from Resource
#==, all, all_path, create, #created_at, #destroy, #eql?, find, #hash, initialize_from_path, #metadata, resource_name, #resource_name, #resource_path, singleton, #to_json, #update, #updated_at
Methods included from Utils
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
15 16 17 18 19 |
# File 'lib/helium/label.rb', line 15 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
28 29 30 31 32 |
# File 'lib/helium/label.rb', line 28 def as_json super.merge({ name: name }) end |
#remove_sensors(sensors_to_remove = []) ⇒ Object
21 22 23 24 25 |
# File 'lib/helium/label.rb', line 21 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
11 12 13 |
# File 'lib/helium/label.rb', line 11 def sensors Collection.new(klass: Sensor, client: @client, belongs_to: self) end |