Class: TestPack1::DataItem
- Defined in:
- lib/test_pack_1/models/data_item.rb
Overview
An object containing time-series data for a specific aggregate, data signal and interval.
Instance Attribute Summary collapse
-
#aggregate ⇒ AggregateModeEnum
How data is aggregated in the asset structure.
-
#aggregate_id ⇒ Integer
The id of this aggregate group: device id, site id, or the constant -1 for portfolio.
-
#calculation ⇒ CalculationModeEnum
Which operation to use when aggregating data.
-
#data ⇒ Array<String, Float>
A data signal.
-
#data_signal ⇒ DataSignal
A data signal.
-
#device_ids ⇒ List of Integer
The ids of the devices in this aggregate group.
-
#resolution ⇒ ResolutionEnum
The resolution for time-series data.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(aggregate = nil, aggregate_id = nil, device_ids = nil, resolution = nil, calculation = nil, data_signal = nil, data = nil) ⇒ DataItem
constructor
A new instance of DataItem.
Methods inherited from BaseModel
Constructor Details
#initialize(aggregate = nil, aggregate_id = nil, device_ids = nil, resolution = nil, calculation = nil, data_signal = nil, data = nil) ⇒ DataItem
Returns a new instance of DataItem.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/test_pack_1/models/data_item.rb', line 52 def initialize(aggregate = nil, aggregate_id = nil, device_ids = nil, resolution = nil, calculation = nil, data_signal = nil, data = nil) @aggregate = aggregate @aggregate_id = aggregate_id @device_ids = device_ids @resolution = resolution @calculation = calculation @data_signal = data_signal @data = data end |
Instance Attribute Details
#aggregate ⇒ AggregateModeEnum
How data is aggregated in the asset structure.
12 13 14 |
# File 'lib/test_pack_1/models/data_item.rb', line 12 def aggregate @aggregate end |
#aggregate_id ⇒ Integer
The id of this aggregate group: device id, site id, or the constant -1 for portfolio
17 18 19 |
# File 'lib/test_pack_1/models/data_item.rb', line 17 def aggregate_id @aggregate_id end |
#calculation ⇒ CalculationModeEnum
Which operation to use when aggregating data.
29 30 31 |
# File 'lib/test_pack_1/models/data_item.rb', line 29 def calculation @calculation end |
#data ⇒ Array<String, Float>
A data signal.
37 38 39 |
# File 'lib/test_pack_1/models/data_item.rb', line 37 def data @data end |
#data_signal ⇒ DataSignal
A data signal.
33 34 35 |
# File 'lib/test_pack_1/models/data_item.rb', line 33 def data_signal @data_signal end |
#device_ids ⇒ List of Integer
The ids of the devices in this aggregate group.
21 22 23 |
# File 'lib/test_pack_1/models/data_item.rb', line 21 def device_ids @device_ids end |
#resolution ⇒ ResolutionEnum
The resolution for time-series data.
25 26 27 |
# File 'lib/test_pack_1/models/data_item.rb', line 25 def resolution @resolution end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/test_pack_1/models/data_item.rb', line 69 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. aggregate = hash['aggregate'] aggregate_id = hash['aggregateId'] device_ids = hash['deviceIds'] resolution = hash['resolution'] calculation = hash['calculation'] data_signal = DataSignal.from_hash(hash['dataSignal']) if hash['dataSignal'] data = hash['data'] # Create object from extracted values. DataItem.new(aggregate, aggregate_id, device_ids, resolution, calculation, data_signal, data) end |
.names ⇒ Object
A mapping from model property names to API property names.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/test_pack_1/models/data_item.rb', line 40 def self.names @_hash = {} if @_hash.nil? @_hash['aggregate'] = 'aggregate' @_hash['aggregate_id'] = 'aggregateId' @_hash['device_ids'] = 'deviceIds' @_hash['resolution'] = 'resolution' @_hash['calculation'] = 'calculation' @_hash['data_signal'] = 'dataSignal' @_hash['data'] = 'data' @_hash end |