Class: TestPack1::PowerCurve
- Defined in:
- lib/test_pack_1/models/power_curve.rb
Overview
PowerCurve Model.
Instance Attribute Summary collapse
-
#device_id ⇒ Integer
The id of a device.
-
#title ⇒ String
The title of the power curve.
-
#values ⇒ List of PowerCurveValue
The title of the power curve.
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(device_id = nil, title = nil, values = nil) ⇒ PowerCurve
constructor
A new instance of PowerCurve.
Methods inherited from BaseModel
Constructor Details
#initialize(device_id = nil, title = nil, values = nil) ⇒ PowerCurve
Returns a new instance of PowerCurve.
30 31 32 33 34 35 36 |
# File 'lib/test_pack_1/models/power_curve.rb', line 30 def initialize(device_id = nil, title = nil, values = nil) @device_id = device_id @title = title @values = values end |
Instance Attribute Details
#device_id ⇒ Integer
The id of a device.
11 12 13 |
# File 'lib/test_pack_1/models/power_curve.rb', line 11 def device_id @device_id end |
#title ⇒ String
The title of the power curve.
15 16 17 |
# File 'lib/test_pack_1/models/power_curve.rb', line 15 def title @title end |
#values ⇒ List of PowerCurveValue
The title of the power curve.
19 20 21 |
# File 'lib/test_pack_1/models/power_curve.rb', line 19 def values @values end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/test_pack_1/models/power_curve.rb', line 39 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. device_id = hash['deviceId'] title = hash['title'] # Parameter is an array, so we need to iterate through it values = nil unless hash['values'].nil? values = [] hash['values'].each do |structure| values << (PowerCurveValue.from_hash(structure) if structure) end end # Create object from extracted values. PowerCurve.new(device_id, title, values) end |
.names ⇒ Object
A mapping from model property names to API property names.
22 23 24 25 26 27 28 |
# File 'lib/test_pack_1/models/power_curve.rb', line 22 def self.names @_hash = {} if @_hash.nil? @_hash['device_id'] = 'deviceId' @_hash['title'] = 'title' @_hash['values'] = 'values' @_hash end |