Class: GoogleMapsPlatform::DistanceMatrixElement
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::DistanceMatrixElement
- Defined in:
- lib/google_maps_platform/models/distance_matrix_element.rb
Overview
DistanceMatrixElement Model.
Instance Attribute Summary collapse
-
#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.
-
#fare ⇒ Fare
The total fare for the route.
-
#status ⇒ DistanceMatrixElementStatus
-
OKindicates the response contains a valid result.
-
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(status:, fare: SKIP, distance: SKIP, duration_in_traffic: SKIP, duration: SKIP, additional_properties: nil) ⇒ DistanceMatrixElement
constructor
A new instance of DistanceMatrixElement.
-
#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(status:, fare: SKIP, distance: SKIP, duration_in_traffic: SKIP, duration: SKIP, additional_properties: nil) ⇒ DistanceMatrixElement
Returns a new instance of DistanceMatrixElement.
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 74 def initialize(status:, fare: SKIP, distance: SKIP, duration_in_traffic: SKIP, duration: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @fare = fare unless fare == SKIP @distance = distance unless distance == SKIP @duration_in_traffic = duration_in_traffic unless duration_in_traffic == SKIP @duration = duration unless duration == SKIP @status = status @additional_properties = additional_properties end |
Instance Attribute Details
#distance ⇒ TextValueObject
An object containing a numeric value and its formatted text representation.
26 27 28 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 26 def distance @distance end |
#duration ⇒ TextValueObject
An object containing a numeric value and its formatted text representation.
36 37 38 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 36 def duration @duration end |
#duration_in_traffic ⇒ TextValueObject
An object containing a numeric value and its formatted text representation.
31 32 33 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 31 def duration_in_traffic @duration_in_traffic end |
#fare ⇒ Fare
The total fare for the route. “‘
"currency" : "USD",
"value" : 6,
"text" : "$6.00"
“‘
21 22 23 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 21 def fare @fare end |
#status ⇒ DistanceMatrixElementStatus
-
OKindicates the response contains a valid result. -
NOT_FOUNDindicates that the origin and/or destination of this pairing
could not be geocoded.
-
ZERO_RESULTSindicates no route could be found between the origin and
destination.
-
MAX_ROUTE_LENGTH_EXCEEDEDindicates the requested route is too long
and cannot be processed.
46 47 48 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 46 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 89 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. status = hash.key?('status') ? hash['status'] : nil fare = Fare.from_hash(hash['fare']) if hash['fare'] distance = TextValueObject.from_hash(hash['distance']) if hash['distance'] duration_in_traffic = TextValueObject.from_hash(hash['duration_in_traffic']) if hash['duration_in_traffic'] duration = TextValueObject.from_hash(hash['duration']) if hash['duration'] # 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. DistanceMatrixElement.new(status: status, fare: fare, distance: distance, duration_in_traffic: duration_in_traffic, duration: duration, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
49 50 51 52 53 54 55 56 57 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 49 def self.names @_hash = {} if @_hash.nil? @_hash['fare'] = 'fare' @_hash['distance'] = 'distance' @_hash['duration_in_traffic'] = 'duration_in_traffic' @_hash['duration'] = 'duration' @_hash['status'] = 'status' @_hash end |
.nullables ⇒ Object
An array for nullable fields
70 71 72 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 70 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
60 61 62 63 64 65 66 67 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 60 def self.optionals %w[ fare distance duration_in_traffic duration ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
125 126 127 128 129 130 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 125 def inspect class_name = self.class.name.split('::').last "<#{class_name} fare: #{@fare.inspect}, distance: #{@distance.inspect},"\ " duration_in_traffic: #{@duration_in_traffic.inspect}, duration: #{@duration.inspect},"\ " status: #{@status.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
117 118 119 120 121 122 |
# File 'lib/google_maps_platform/models/distance_matrix_element.rb', line 117 def to_s class_name = self.class.name.split('::').last "<#{class_name} fare: #{@fare}, distance: #{@distance}, duration_in_traffic:"\ " #{@duration_in_traffic}, duration: #{@duration}, status: #{@status},"\ " additional_properties: #{@additional_properties}>" end |