Class: TestPack1::DataItem

Inherits:
BaseModel show all
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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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

#aggregateAggregateModeEnum

How data is aggregated in the asset structure.

Returns:



12
13
14
# File 'lib/test_pack_1/models/data_item.rb', line 12

def aggregate
  @aggregate
end

#aggregate_idInteger

The id of this aggregate group: device id, site id, or the constant -1 for portfolio

Returns:

  • (Integer)


17
18
19
# File 'lib/test_pack_1/models/data_item.rb', line 17

def aggregate_id
  @aggregate_id
end

#calculationCalculationModeEnum

Which operation to use when aggregating data.

Returns:



29
30
31
# File 'lib/test_pack_1/models/data_item.rb', line 29

def calculation
  @calculation
end

#dataArray<String, Float>

A data signal.

Returns:



37
38
39
# File 'lib/test_pack_1/models/data_item.rb', line 37

def data
  @data
end

#data_signalDataSignal

A data signal.

Returns:



33
34
35
# File 'lib/test_pack_1/models/data_item.rb', line 33

def data_signal
  @data_signal
end

#device_idsList of Integer

The ids of the devices in this aggregate group.

Returns:

  • (List of Integer)


21
22
23
# File 'lib/test_pack_1/models/data_item.rb', line 21

def device_ids
  @device_ids
end

#resolutionResolutionEnum

The resolution for time-series data.

Returns:



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

.namesObject

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