Class: ShellEv::MultiLocationMarker
- Defined in:
- lib/shell_ev/models/multi_location_marker.rb
Overview
A Marker is a place on the map that represent multiple Locations at the same spot
Instance Attribute Summary collapse
-
#coordinates ⇒ Coordinates
Coordinates of the Shell Recharge Site Location.
-
#evse_count ⇒ Float
Total number of Evses in Locations that this Marker represents.
-
#geo_hash ⇒ String
GeoHash of marker coordinates.
-
#location_count ⇒ Float
Number of Locations that this Marker represents in the given set of bounds.
-
#marker_type ⇒ String
Identifies the marker type.
-
#max_power ⇒ Float
Maximum power in kW across all locations grouped in this marker (disregarding availability).
-
#unique_key ⇒ String
Uniquely identifies the marker object.
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.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(marker_type = nil, unique_key = SKIP, coordinates = SKIP, location_count = SKIP, evse_count = SKIP, max_power = SKIP, geo_hash = SKIP) ⇒ MultiLocationMarker
constructor
A new instance of MultiLocationMarker.
Methods inherited from BaseModel
Constructor Details
#initialize(marker_type = nil, unique_key = SKIP, coordinates = SKIP, location_count = SKIP, evse_count = SKIP, max_power = SKIP, geo_hash = SKIP) ⇒ MultiLocationMarker
Returns a new instance of MultiLocationMarker.
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 73 def initialize(marker_type = nil, unique_key = SKIP, coordinates = SKIP, location_count = SKIP, evse_count = SKIP, max_power = SKIP, geo_hash = SKIP) @marker_type = marker_type @unique_key = unique_key unless unique_key == SKIP @coordinates = coordinates unless coordinates == SKIP @location_count = location_count unless location_count == SKIP @evse_count = evse_count unless evse_count == SKIP @max_power = max_power unless max_power == SKIP @geo_hash = geo_hash unless geo_hash == SKIP end |
Instance Attribute Details
#coordinates ⇒ Coordinates
Coordinates of the Shell Recharge Site Location
24 25 26 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 24 def coordinates @coordinates end |
#evse_count ⇒ Float
Total number of Evses in Locations that this Marker represents
32 33 34 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 32 def evse_count @evse_count end |
#geo_hash ⇒ String
GeoHash of marker coordinates
41 42 43 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 41 def geo_hash @geo_hash end |
#location_count ⇒ Float
Number of Locations that this Marker represents in the given set of bounds
28 29 30 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 28 def location_count @location_count end |
#marker_type ⇒ String
Identifies the marker type. If it’s a ‘MultiLocationMarker`, then the value is `MultiLocation`
16 17 18 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 16 def marker_type @marker_type end |
#max_power ⇒ Float
Maximum power in kW across all locations grouped in this marker (disregarding availability)
37 38 39 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 37 def max_power @max_power end |
#unique_key ⇒ String
Uniquely identifies the marker object
20 21 22 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 20 def unique_key @unique_key end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 86 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. marker_type = hash.key?('markerType') ? hash['markerType'] : nil unique_key = hash.key?('uniqueKey') ? hash['uniqueKey'] : SKIP coordinates = Coordinates.from_hash(hash['coordinates']) if hash['coordinates'] location_count = hash.key?('locationCount') ? hash['locationCount'] : SKIP evse_count = hash.key?('evseCount') ? hash['evseCount'] : SKIP max_power = hash.key?('maxPower') ? hash['maxPower'] : SKIP geo_hash = hash.key?('geoHash') ? hash['geoHash'] : SKIP # Create object from extracted values. MultiLocationMarker.new(marker_type, unique_key, coordinates, location_count, evse_count, max_power, geo_hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 44 def self.names @_hash = {} if @_hash.nil? @_hash['marker_type'] = 'markerType' @_hash['unique_key'] = 'uniqueKey' @_hash['coordinates'] = 'coordinates' @_hash['location_count'] = 'locationCount' @_hash['evse_count'] = 'evseCount' @_hash['max_power'] = 'maxPower' @_hash['geo_hash'] = 'geoHash' @_hash end |
.nullables ⇒ Object
An array for nullable fields
69 70 71 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 69 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 57 def self.optionals %w[ unique_key coordinates location_count evse_count max_power geo_hash ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/shell_ev/models/multi_location_marker.rb', line 110 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.marker_type, ->(val) { val.instance_of? String }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['markerType'], ->(val) { val.instance_of? String }) end |