Class: TestPack1::Device
- Defined in:
- lib/test_pack_1/models/device.rb
Overview
Device Model.
Instance Attribute Summary collapse
-
#alt_title ⇒ String
An alternative title.
-
#bidding_area ⇒ String
Only applies to Nordic countries and the UK.
-
#child_ids ⇒ List of Integer
Ids of child devices, if any.
-
#device_id ⇒ Integer
The id of a device.
-
#device_model ⇒ DeviceModel
General device model information.
-
#device_type ⇒ String
The string representation of the device type.
-
#device_type_id ⇒ Integer
The id of a device type.
-
#elevation ⇒ String
The elevation of the device in meters above sea level.
-
#identity ⇒ String
Device identification number.
-
#latitude ⇒ String
The latitude of the device in the WGS84 system.
-
#longitude ⇒ String
The longitude of the device in the WGS84 system.
-
#max_power ⇒ Integer
The maximum power for a device.
-
#metadata ⇒ List of MetadataField
A list of metadata fields and their values.
-
#parent_id ⇒ Integer
The id of the parent device, if any.
-
#site ⇒ Site
Device identification number.
-
#target_availability ⇒ Float
The target availability for the device.
-
#timestamp_start ⇒ DateTime
The earliest timestamp device data is available for.
-
#title ⇒ String
The id of a device.
-
#turbine_type ⇒ TurbineType
Turbine-specific type information.
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
Methods inherited from BaseModel
Constructor Details
#initialize(device_id = nil, title = nil, alt_title = nil, identity = nil, site = nil, device_type = nil, device_type_id = nil, parent_id = nil, child_ids = nil, device_model = nil, turbine_type = nil, max_power = nil, bidding_area = nil, timestamp_start = nil, latitude = nil, longitude = nil, elevation = nil, target_availability = nil, metadata = nil) ⇒ Device
Returns a new instance of Device.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/test_pack_1/models/device.rb', line 111 def initialize(device_id = nil, title = nil, alt_title = nil, identity = nil, site = nil, device_type = nil, device_type_id = nil, parent_id = nil, child_ids = nil, device_model = nil, turbine_type = nil, max_power = nil, bidding_area = nil, = nil, latitude = nil, longitude = nil, elevation = nil, target_availability = nil, = nil) @device_id = device_id @title = title @alt_title = alt_title @identity = identity @site = site @device_type = device_type @device_type_id = device_type_id @parent_id = parent_id @child_ids = child_ids @device_model = device_model @turbine_type = turbine_type @max_power = max_power @bidding_area = bidding_area = @latitude = latitude @longitude = longitude @elevation = elevation @target_availability = target_availability = end |
Instance Attribute Details
#alt_title ⇒ String
An alternative title.
20 21 22 |
# File 'lib/test_pack_1/models/device.rb', line 20 def alt_title @alt_title end |
#bidding_area ⇒ String
Only applies to Nordic countries and the UK.
60 61 62 |
# File 'lib/test_pack_1/models/device.rb', line 60 def bidding_area @bidding_area end |
#child_ids ⇒ List of Integer
Ids of child devices, if any.
44 45 46 |
# File 'lib/test_pack_1/models/device.rb', line 44 def child_ids @child_ids end |
#device_id ⇒ Integer
The id of a device.
12 13 14 |
# File 'lib/test_pack_1/models/device.rb', line 12 def device_id @device_id end |
#device_model ⇒ DeviceModel
General device model information.
48 49 50 |
# File 'lib/test_pack_1/models/device.rb', line 48 def device_model @device_model end |
#device_type ⇒ String
The string representation of the device type.
32 33 34 |
# File 'lib/test_pack_1/models/device.rb', line 32 def device_type @device_type end |
#device_type_id ⇒ Integer
The id of a device type.
36 37 38 |
# File 'lib/test_pack_1/models/device.rb', line 36 def device_type_id @device_type_id end |
#elevation ⇒ String
The elevation of the device in meters above sea level.
76 77 78 |
# File 'lib/test_pack_1/models/device.rb', line 76 def elevation @elevation end |
#identity ⇒ String
Device identification number.
24 25 26 |
# File 'lib/test_pack_1/models/device.rb', line 24 def identity @identity end |
#latitude ⇒ String
The latitude of the device in the WGS84 system.
68 69 70 |
# File 'lib/test_pack_1/models/device.rb', line 68 def latitude @latitude end |
#longitude ⇒ String
The longitude of the device in the WGS84 system.
72 73 74 |
# File 'lib/test_pack_1/models/device.rb', line 72 def longitude @longitude end |
#max_power ⇒ Integer
The maximum power for a device.
56 57 58 |
# File 'lib/test_pack_1/models/device.rb', line 56 def max_power @max_power end |
#metadata ⇒ List of MetadataField
A list of metadata fields and their values.
84 85 86 |
# File 'lib/test_pack_1/models/device.rb', line 84 def end |
#parent_id ⇒ Integer
The id of the parent device, if any.
40 41 42 |
# File 'lib/test_pack_1/models/device.rb', line 40 def parent_id @parent_id end |
#site ⇒ Site
Device identification number.
28 29 30 |
# File 'lib/test_pack_1/models/device.rb', line 28 def site @site end |
#target_availability ⇒ Float
The target availability for the device.
80 81 82 |
# File 'lib/test_pack_1/models/device.rb', line 80 def target_availability @target_availability end |
#timestamp_start ⇒ DateTime
The earliest timestamp device data is available for.
64 65 66 |
# File 'lib/test_pack_1/models/device.rb', line 64 def end |
#title ⇒ String
The id of a device.
16 17 18 |
# File 'lib/test_pack_1/models/device.rb', line 16 def title @title end |
#turbine_type ⇒ TurbineType
Turbine-specific type information.
52 53 54 |
# File 'lib/test_pack_1/models/device.rb', line 52 def turbine_type @turbine_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/test_pack_1/models/device.rb', line 152 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. device_id = hash['deviceId'] title = hash['title'] alt_title = hash['altTitle'] identity = hash['identity'] site = Site.from_hash(hash['site']) if hash['site'] device_type = hash['deviceType'] device_type_id = hash['deviceTypeId'] parent_id = hash['parentId'] child_ids = hash['childIds'] device_model = DeviceModel.from_hash(hash['deviceModel']) if hash['deviceModel'] turbine_type = TurbineType.from_hash(hash['turbineType']) if hash['turbineType'] max_power = hash['maxPower'] bidding_area = hash['biddingArea'] = APIHelper.rfc3339(hash['timestampStart']) if hash['timestampStart'] latitude = hash['latitude'] longitude = hash['longitude'] elevation = hash['elevation'] target_availability = hash['targetAvailability'] # Parameter is an array, so we need to iterate through it = nil unless hash['metadata'].nil? = [] hash['metadata'].each do |structure| << (MetadataField.from_hash(structure) if structure) end end # Create object from extracted values. Device.new(device_id, title, alt_title, identity, site, device_type, device_type_id, parent_id, child_ids, device_model, turbine_type, max_power, bidding_area, , latitude, longitude, elevation, target_availability, ) end |
.names ⇒ Object
A mapping from model property names to API property names.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/test_pack_1/models/device.rb', line 87 def self.names @_hash = {} if @_hash.nil? @_hash['device_id'] = 'deviceId' @_hash['title'] = 'title' @_hash['alt_title'] = 'altTitle' @_hash['identity'] = 'identity' @_hash['site'] = 'site' @_hash['device_type'] = 'deviceType' @_hash['device_type_id'] = 'deviceTypeId' @_hash['parent_id'] = 'parentId' @_hash['child_ids'] = 'childIds' @_hash['device_model'] = 'deviceModel' @_hash['turbine_type'] = 'turbineType' @_hash['max_power'] = 'maxPower' @_hash['bidding_area'] = 'biddingArea' @_hash['timestamp_start'] = 'timestampStart' @_hash['latitude'] = 'latitude' @_hash['longitude'] = 'longitude' @_hash['elevation'] = 'elevation' @_hash['target_availability'] = 'targetAvailability' @_hash['metadata'] = 'metadata' @_hash end |