Class: TempoIQ::Device
- Inherits:
-
Object
- Object
- TempoIQ::Device
- Defined in:
- lib/tempoiq/models/device.rb
Overview
The top level container for a group of sensors.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Indexable attributes.
-
#key ⇒ Object
readonly
The primary key of the device [String].
-
#name ⇒ Object
Human readable name of the device [String] EG - “My Device”.
-
#sensors ⇒ Object
Sensors attached to the device [Array] (Sensor).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, name = "", attributes = {}, *sensors) ⇒ Device
constructor
A new instance of Device.
- #to_hash ⇒ Object
Constructor Details
#initialize(key, name = "", attributes = {}, *sensors) ⇒ Device
Returns a new instance of Device.
19 20 21 22 23 24 |
# File 'lib/tempoiq/models/device.rb', line 19 def initialize(key, name = "", attributes = {}, *sensors) @key = key @name = name @attributes = attributes @sensors = sensors end |
Instance Attribute Details
#attributes ⇒ Object
Indexable attributes. Useful for grouping related Devices. EG - => ‘445-w-Erie’, ‘model’ => ‘TX75’, ‘region’ => ‘Southwest’
14 15 16 |
# File 'lib/tempoiq/models/device.rb', line 14 def attributes @attributes end |
#key ⇒ Object (readonly)
The primary key of the device [String]
7 8 9 |
# File 'lib/tempoiq/models/device.rb', line 7 def key @key end |
#name ⇒ Object
Human readable name of the device [String] EG - “My Device”
10 11 12 |
# File 'lib/tempoiq/models/device.rb', line 10 def name @name end |
#sensors ⇒ Object
Sensors attached to the device [Array] (Sensor)
17 18 19 |
# File 'lib/tempoiq/models/device.rb', line 17 def sensors @sensors end |
Class Method Details
Instance Method Details
#to_hash ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/tempoiq/models/device.rb', line 31 def to_hash { 'key' => key, 'name' => name, 'attributes' => attributes, 'sensors' => sensors.map(&:to_hash) } end |