Class: GoogleMapsPlatform::DirectionsLeg
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::DirectionsLeg
- Defined in:
- lib/google_maps_platform/models/directions_leg.rb
Overview
DirectionsLeg Model.
Instance Attribute Summary collapse
-
#arrival_time ⇒ TimeZoneTextValueObject
An object containing Unix time, a time zone, and its formatted text representation.
-
#departure_time ⇒ TimeZoneTextValueObject
An object containing Unix time, a time zone, and its formatted text representation.
-
#distance ⇒ TextValueObject
An object containing a numeric value and its formatted text representation.
-
#duration ⇒ TextValueObject
An object containing a numeric value and its formatted text representation.
-
#duration_in_traffic ⇒ TextValueObject
An object containing a numeric value and its formatted text representation.
-
#end_address ⇒ String
Contains the human-readable address (typically a street address) from reverse geocoding the
end_locationof this leg. -
#end_location ⇒ LatLngLiteral
An object describing a specific location with Latitude and Longitude in decimal degrees.
-
#start_address ⇒ String
Contains the human-readable address (typically a street address) resulting from reverse geocoding the
start_locationof this leg. -
#start_location ⇒ LatLngLiteral
An object describing a specific location with Latitude and Longitude in decimal degrees.
-
#steps ⇒ Array[DirectionsStep]
An array of steps denoting information about each separate step of the leg of the journey.
-
#traffic_speed_entry ⇒ Array[DirectionsTrafficSpeedEntry]
Information about traffic speed along the leg.
-
#via_waypoint ⇒ Array[DirectionsViaWaypoint]
The locations of via waypoints along this leg.
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.
Instance Method Summary collapse
-
#initialize(end_address:, end_location:, start_address:, start_location:, steps:, traffic_speed_entry:, via_waypoint:, arrival_time: SKIP, departure_time: SKIP, distance: SKIP, duration: SKIP, duration_in_traffic: SKIP, additional_properties: nil) ⇒ DirectionsLeg
constructor
A new instance of DirectionsLeg.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(end_address:, end_location:, start_address:, start_location:, steps:, traffic_speed_entry:, via_waypoint:, arrival_time: SKIP, departure_time: SKIP, distance: SKIP, duration: SKIP, duration_in_traffic: SKIP, additional_properties: nil) ⇒ DirectionsLeg
Returns a new instance of DirectionsLeg.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 107 def initialize(end_address:, end_location:, start_address:, start_location:, steps:, traffic_speed_entry:, via_waypoint:, arrival_time: SKIP, departure_time: SKIP, distance: SKIP, duration: SKIP, duration_in_traffic: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @arrival_time = arrival_time unless arrival_time == SKIP @departure_time = departure_time unless departure_time == SKIP @distance = distance unless distance == SKIP @duration = duration unless duration == SKIP @duration_in_traffic = duration_in_traffic unless duration_in_traffic == SKIP @end_address = end_address @end_location = end_location @start_address = start_address @start_location = start_location @steps = steps @traffic_speed_entry = traffic_speed_entry @via_waypoint = via_waypoint @additional_properties = additional_properties end |
Instance Attribute Details
#arrival_time ⇒ TimeZoneTextValueObject
An object containing Unix time, a time zone, and its formatted text representation.
15 16 17 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 15 def arrival_time @arrival_time end |
#departure_time ⇒ TimeZoneTextValueObject
An object containing Unix time, a time zone, and its formatted text representation.
20 21 22 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 20 def departure_time @departure_time end |
#distance ⇒ TextValueObject
An object containing a numeric value and its formatted text representation.
25 26 27 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 25 def distance @distance end |
#duration ⇒ TextValueObject
An object containing a numeric value and its formatted text representation.
30 31 32 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 30 def duration @duration end |
#duration_in_traffic ⇒ TextValueObject
An object containing a numeric value and its formatted text representation.
35 36 37 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 35 def duration_in_traffic @duration_in_traffic end |
#end_address ⇒ String
Contains the human-readable address (typically a street address) from reverse geocoding the end_location of this leg. This content is meant to be read as-is. Do not programmatically parse the formatted address.
41 42 43 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 41 def end_address @end_address end |
#end_location ⇒ LatLngLiteral
An object describing a specific location with Latitude and Longitude in decimal degrees.
46 47 48 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 46 def end_location @end_location end |
#start_address ⇒ String
Contains the human-readable address (typically a street address) resulting from reverse geocoding the start_location of this leg. This content is meant to be read as-is. Do not programmatically parse the formatted address.
53 54 55 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 53 def start_address @start_address end |
#start_location ⇒ LatLngLiteral
An object describing a specific location with Latitude and Longitude in decimal degrees.
58 59 60 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 58 def start_location @start_location end |
#steps ⇒ Array[DirectionsStep]
An array of steps denoting information about each separate step of the leg of the journey.
63 64 65 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 63 def steps @steps end |
#traffic_speed_entry ⇒ Array[DirectionsTrafficSpeedEntry]
Information about traffic speed along the leg.
67 68 69 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 67 def traffic_speed_entry @traffic_speed_entry end |
#via_waypoint ⇒ Array[DirectionsViaWaypoint]
The locations of via waypoints along this leg.
71 72 73 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 71 def via_waypoint @via_waypoint end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 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 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 131 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. end_address = hash.key?('end_address') ? hash['end_address'] : nil end_location = LatLngLiteral.from_hash(hash['end_location']) if hash['end_location'] start_address = hash.key?('start_address') ? hash['start_address'] : nil start_location = LatLngLiteral.from_hash(hash['start_location']) if hash['start_location'] # Parameter is an array, so we need to iterate through it steps = nil unless hash['steps'].nil? steps = [] hash['steps'].each do |structure| steps << (DirectionsStep.from_hash(structure) if structure) end end steps = nil unless hash.key?('steps') # Parameter is an array, so we need to iterate through it traffic_speed_entry = nil unless hash['traffic_speed_entry'].nil? traffic_speed_entry = [] hash['traffic_speed_entry'].each do |structure| traffic_speed_entry << (DirectionsTrafficSpeedEntry.from_hash(structure) if structure) end end traffic_speed_entry = nil unless hash.key?('traffic_speed_entry') # Parameter is an array, so we need to iterate through it via_waypoint = nil unless hash['via_waypoint'].nil? via_waypoint = [] hash['via_waypoint'].each do |structure| via_waypoint << (DirectionsViaWaypoint.from_hash(structure) if structure) end end via_waypoint = nil unless hash.key?('via_waypoint') arrival_time = TimeZoneTextValueObject.from_hash(hash['arrival_time']) if hash['arrival_time'] departure_time = TimeZoneTextValueObject.from_hash(hash['departure_time']) if hash['departure_time'] distance = TextValueObject.from_hash(hash['distance']) if hash['distance'] duration = TextValueObject.from_hash(hash['duration']) if hash['duration'] duration_in_traffic = TextValueObject.from_hash(hash['duration_in_traffic']) if hash['duration_in_traffic'] # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. DirectionsLeg.new(end_address: end_address, end_location: end_location, start_address: start_address, start_location: start_location, steps: steps, traffic_speed_entry: traffic_speed_entry, via_waypoint: via_waypoint, arrival_time: arrival_time, departure_time: departure_time, distance: distance, duration: duration, duration_in_traffic: duration_in_traffic, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 74 def self.names @_hash = {} if @_hash.nil? @_hash['arrival_time'] = 'arrival_time' @_hash['departure_time'] = 'departure_time' @_hash['distance'] = 'distance' @_hash['duration'] = 'duration' @_hash['duration_in_traffic'] = 'duration_in_traffic' @_hash['end_address'] = 'end_address' @_hash['end_location'] = 'end_location' @_hash['start_address'] = 'start_address' @_hash['start_location'] = 'start_location' @_hash['steps'] = 'steps' @_hash['traffic_speed_entry'] = 'traffic_speed_entry' @_hash['via_waypoint'] = 'via_waypoint' @_hash end |
.nullables ⇒ Object
An array for nullable fields
103 104 105 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 103 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
92 93 94 95 96 97 98 99 100 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 92 def self.optionals %w[ arrival_time departure_time distance duration duration_in_traffic ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 213 def inspect class_name = self.class.name.split('::').last "<#{class_name} arrival_time: #{@arrival_time.inspect}, departure_time:"\ " #{@departure_time.inspect}, distance: #{@distance.inspect}, duration:"\ " #{@duration.inspect}, duration_in_traffic: #{@duration_in_traffic.inspect}, end_address:"\ " #{@end_address.inspect}, end_location: #{@end_location.inspect}, start_address:"\ " #{@start_address.inspect}, start_location: #{@start_location.inspect}, steps:"\ " #{@steps.inspect}, traffic_speed_entry: #{@traffic_speed_entry.inspect}, via_waypoint:"\ " #{@via_waypoint.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
202 203 204 205 206 207 208 209 210 |
# File 'lib/google_maps_platform/models/directions_leg.rb', line 202 def to_s class_name = self.class.name.split('::').last "<#{class_name} arrival_time: #{@arrival_time}, departure_time: #{@departure_time},"\ " distance: #{@distance}, duration: #{@duration}, duration_in_traffic:"\ " #{@duration_in_traffic}, end_address: #{@end_address}, end_location: #{@end_location},"\ " start_address: #{@start_address}, start_location: #{@start_location}, steps: #{@steps},"\ " traffic_speed_entry: #{@traffic_speed_entry}, via_waypoint: #{@via_waypoint},"\ " additional_properties: #{@additional_properties}>" end |