class TempoIQ::Device

The top level container for a group of sensors.

Attributes

attributes[RW]

Indexable attributes. Useful for grouping related Devices. EG - {'location' => '445-w-Erie', 'model' => 'TX75', 'region' => 'Southwest'}

key[R]

The primary key of the device [String]

name[RW]

Human readable name of the device [String] EG - “My Device”

sensors[RW]

Sensors attached to the device [Array] (Sensor)

Public Class Methods

from_hash(hash) click to toggle source
# File lib/tempoiq/models/device.rb, line 26
def self.from_hash(hash)
  new(hash['key'], hash['name'], hash['attributes'],
      *hash['sensors'].map { |s| Sensor.new(s['key'], s['name'], s['attributes']) })
end
new(key, name = "", attributes = {}, *sensors) click to toggle source
# File lib/tempoiq/models/device.rb, line 19
def initialize(key, name = "", attributes = {}, *sensors)
  @key = key
  @name = name
  @attributes = attributes
  @sensors = sensors
end

Public Instance Methods

to_hash() click to toggle source
# File lib/tempoiq/models/device.rb, line 31
def to_hash
  {
    'key' => key,
    'name' => name,
    'attributes' => attributes,
    'sensors' => sensors.map(&:to_hash)
  }
end