Class: TestPack1::DataPerCategoryItem

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/test_pack_1/models/data_per_category_item.rb

Overview

Data for a single aggregate group and contract category combination.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(aggregate_id = nil, device_ids = nil, contract_title = nil, category_title = nil, value = nil, duration = nil) ⇒ DataPerCategoryItem

Returns a new instance of DataPerCategoryItem.



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/test_pack_1/models/data_per_category_item.rb', line 47

def initialize(aggregate_id = nil,
               device_ids = nil,
               contract_title = nil,
               category_title = nil,
               value = nil,
               duration = nil)
  @aggregate_id = aggregate_id
  @device_ids = device_ids
  @contract_title = contract_title
  @category_title = category_title
  @value = value
  @duration = duration
end

Instance Attribute Details

#aggregate_idInteger

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

Returns:

  • (Integer)


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

def aggregate_id
  @aggregate_id
end

#category_titleString

The ids of the devices in this aggregate group.

Returns:



24
25
26
# File 'lib/test_pack_1/models/data_per_category_item.rb', line 24

def category_title
  @category_title
end

#contract_titleString

The ids of the devices in this aggregate group.

Returns:



20
21
22
# File 'lib/test_pack_1/models/data_per_category_item.rb', line 20

def contract_title
  @contract_title
end

#device_idsList of Integer

The ids of the devices in this aggregate group.

Returns:

  • (List of Integer)


16
17
18
# File 'lib/test_pack_1/models/data_per_category_item.rb', line 16

def device_ids
  @device_ids
end

#durationFloat

The summed duration in seconds allocated to this contract category and aggregate group.

Returns:

  • (Float)


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

def duration
  @duration
end

#valueFloat

The aggregated value of the selected data signal.

Returns:

  • (Float)


28
29
30
# File 'lib/test_pack_1/models/data_per_category_item.rb', line 28

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/test_pack_1/models/data_per_category_item.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  aggregate_id = hash['aggregateId']
  device_ids = hash['deviceIds']
  contract_title = hash['contractTitle']
  category_title = hash['categoryTitle']
  value = hash['value']
  duration = hash['duration']

  # Create object from extracted values.
  DataPerCategoryItem.new(aggregate_id,
                          device_ids,
                          contract_title,
                          category_title,
                          value,
                          duration)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
43
44
45
# File 'lib/test_pack_1/models/data_per_category_item.rb', line 36

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['aggregate_id'] = 'aggregateId'
  @_hash['device_ids'] = 'deviceIds'
  @_hash['contract_title'] = 'contractTitle'
  @_hash['category_title'] = 'categoryTitle'
  @_hash['value'] = 'value'
  @_hash['duration'] = 'duration'
  @_hash
end