Class: ShellEv::MultiLocationMarkerV2

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/shell_ev/models/multi_location_marker_v2.rb

Overview

A Marker is a place on the map that represent multiple Locations at the same spot

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(coordinates = SKIP, location_count = SKIP, evse_count = SKIP, max_power = SKIP, operator_name = SKIP) ⇒ MultiLocationMarkerV2

Returns a new instance of MultiLocationMarkerV2.



66
67
68
69
70
71
72
73
74
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 66

def initialize(coordinates = SKIP, location_count = SKIP, evse_count = SKIP,
               max_power = SKIP, operator_name = 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
  @operator_name = operator_name unless operator_name == SKIP
  @marker_type = 'MultiLocation'
end

Instance Attribute Details

#coordinatesCoordinates

Coordinates of the Shell Recharge Site Location

Returns:



15
16
17
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 15

def coordinates
  @coordinates
end

#evse_countFloat

Total number of Evses in Locations that this Marker represents

Returns:

  • (Float)


23
24
25
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 23

def evse_count
  @evse_count
end

#location_countFloat

Number of Locations that this Marker represents in the given set of bounds

Returns:

  • (Float)


19
20
21
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 19

def location_count
  @location_count
end

#marker_typeString (readonly)

Type of the Marker, in this case it will always be MultiLocation

Returns:

  • (String)


36
37
38
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 36

def marker_type
  @marker_type
end

#max_powerFloat

Maximum power in kW across all locations grouped in this marker (disregarding availability)

Returns:

  • (Float)


28
29
30
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 28

def max_power
  @max_power
end

#operator_nameString

Operator of this Shell Recharge Location

Returns:

  • (String)


32
33
34
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 32

def operator_name
  @operator_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 77

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  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
  operator_name = hash.key?('operatorName') ? hash['operatorName'] : SKIP

  # Create object from extracted values.
  MultiLocationMarkerV2.new(coordinates,
                            location_count,
                            evse_count,
                            max_power,
                            operator_name)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
48
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['coordinates'] = 'coordinates'
  @_hash['location_count'] = 'locationCount'
  @_hash['evse_count'] = 'evseCount'
  @_hash['max_power'] = 'maxPower'
  @_hash['operator_name'] = 'operatorName'
  @_hash['marker_type'] = 'markerType'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



51
52
53
54
55
56
57
58
59
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 51

def self.optionals
  %w[
    coordinates
    location_count
    evse_count
    max_power
    operator_name
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 97

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



118
119
120
121
122
123
124
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 118

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} coordinates: #{@coordinates.inspect}, location_count:"\
  " #{@location_count.inspect}, evse_count: #{@evse_count.inspect}, max_power:"\
  " #{@max_power.inspect}, operator_name: #{@operator_name.inspect}, marker_type:"\
  " #{@marker_type.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



110
111
112
113
114
115
# File 'lib/shell_ev/models/multi_location_marker_v2.rb', line 110

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} coordinates: #{@coordinates}, location_count: #{@location_count},"\
  " evse_count: #{@evse_count}, max_power: #{@max_power}, operator_name: #{@operator_name},"\
  " marker_type: #{@marker_type}>"
end