Class: GoogleMapsPlatform::DistanceMatrixRow
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::DistanceMatrixRow
- Defined in:
- lib/google_maps_platform/models/distance_matrix_row.rb
Overview
DistanceMatrixRow Model.
Instance Attribute Summary collapse
-
#elements ⇒ Array[DistanceMatrixElement]
When the Distance Matrix API returns results, it places them within a JSON rows array.
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(elements:, additional_properties: nil) ⇒ DistanceMatrixRow
constructor
A new instance of DistanceMatrixRow.
-
#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(elements:, additional_properties: nil) ⇒ DistanceMatrixRow
Returns a new instance of DistanceMatrixRow.
40 41 42 43 44 45 46 |
# File 'lib/google_maps_platform/models/distance_matrix_row.rb', line 40 def initialize(elements:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @elements = elements @additional_properties = additional_properties end |
Instance Attribute Details
#elements ⇒ Array[DistanceMatrixElement]
When the Distance Matrix API returns results, it places them within a JSON rows array. Even if no results are returned (such as when the origins and/or destinations don’t exist), it still returns an empty array. Rows are ordered according to the values in the origin parameter of the request. Each row corresponds to an origin, and each element within that row corresponds to a pairing of the origin with a destination value. Each row array contains one or more element entries, which in turn contain the information about a single origin-destination pairing.
21 22 23 |
# File 'lib/google_maps_platform/models/distance_matrix_row.rb', line 21 def elements @elements end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/google_maps_platform/models/distance_matrix_row.rb', line 49 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it elements = nil unless hash['elements'].nil? elements = [] hash['elements'].each do |structure| elements << (DistanceMatrixElement.from_hash(structure) if structure) end end elements = nil unless hash.key?('elements') # 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. DistanceMatrixRow.new(elements: elements, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
24 25 26 27 28 |
# File 'lib/google_maps_platform/models/distance_matrix_row.rb', line 24 def self.names @_hash = {} if @_hash.nil? @_hash['elements'] = 'elements' @_hash end |
.nullables ⇒ Object
An array for nullable fields
36 37 38 |
# File 'lib/google_maps_platform/models/distance_matrix_row.rb', line 36 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
31 32 33 |
# File 'lib/google_maps_platform/models/distance_matrix_row.rb', line 31 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
83 84 85 86 87 |
# File 'lib/google_maps_platform/models/distance_matrix_row.rb', line 83 def inspect class_name = self.class.name.split('::').last "<#{class_name} elements: #{@elements.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
77 78 79 80 |
# File 'lib/google_maps_platform/models/distance_matrix_row.rb', line 77 def to_s class_name = self.class.name.split('::').last "<#{class_name} elements: #{@elements}, additional_properties: #{@additional_properties}>" end |