Class: GoogleMapsPlatform::GeocodingResult
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::GeocodingResult
- Defined in:
- lib/google_maps_platform/models/geocoding_result.rb
Overview
GeocodingResult Model.
Instance Attribute Summary collapse
-
#address_components ⇒ Array[AddressComponent]
An array containing the separate components applicable to this address.
-
#formatted_address ⇒ String
The human-readable address of this location.
-
#geometry ⇒ GeocodingGeometry
An object describing the location.
-
#partial_match ⇒ TrueClass | FalseClass
Indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the requested address.
-
#place_id ⇒ String
A unique identifier that can be used with other Google APIs.
-
#plus_code ⇒ PlusCode
An encoded location reference, derived from latitude and longitude coordinates, that represents an area, 1/8000th of a degree by 1/8000th of a degree (about 14m x 14m at the equator) or smaller.
-
#postcode_localities ⇒ Array[String]
An array denoting all the localities contained in a postal code.
-
#types ⇒ Array[String]
The
types[]array indicates the type of the returned 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(address_components:, formatted_address:, geometry:, place_id:, types:, plus_code: SKIP, postcode_localities: SKIP, partial_match: SKIP, additional_properties: nil) ⇒ GeocodingResult
constructor
A new instance of GeocodingResult.
-
#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(address_components:, formatted_address:, geometry:, place_id:, types:, plus_code: SKIP, postcode_localities: SKIP, partial_match: SKIP, additional_properties: nil) ⇒ GeocodingResult
Returns a new instance of GeocodingResult.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 93 def initialize(address_components:, formatted_address:, geometry:, place_id:, types:, plus_code: SKIP, postcode_localities: SKIP, partial_match: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @address_components = address_components @formatted_address = formatted_address @geometry = geometry @place_id = place_id @plus_code = plus_code unless plus_code == SKIP @types = types @postcode_localities = postcode_localities unless postcode_localities == SKIP @partial_match = partial_match unless partial_match == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#address_components ⇒ Array[AddressComponent]
An array containing the separate components applicable to this address.
14 15 16 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 14 def address_components @address_components end |
#formatted_address ⇒ String
The human-readable address of this location.
18 19 20 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 18 def formatted_address @formatted_address end |
#geometry ⇒ GeocodingGeometry
An object describing the location.
22 23 24 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 22 def geometry @geometry end |
#partial_match ⇒ TrueClass | FalseClass
Indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the requested address. You may wish to examine the original request for misspellings and/or an incomplete address. Partial matches most often occur for street addresses that do not exist within the locality you pass in the request. Partial matches may also be returned when a request matches two or more locations in the same locality.
63 64 65 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 63 def partial_match @partial_match end |
#place_id ⇒ String
A unique identifier that can be used with other Google APIs. For example, you can use the place_id in a Places API request to get details of a local business, such as phone number, opening hours, user reviews, and more. See the [place ID overview](developers.google.com/places/place-id).
30 31 32 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 30 def place_id @place_id end |
#plus_code ⇒ PlusCode
An encoded location reference, derived from latitude and longitude coordinates, that represents an area, 1/8000th of a degree by 1/8000th of a degree (about 14m x 14m at the equator) or smaller. Plus codes can be used as a replacement for street addresses in places where they do not exist (where buildings are not numbered or streets are not named).
38 39 40 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 38 def plus_code @plus_code end |
#postcode_localities ⇒ Array[String]
An array denoting all the localities contained in a postal code. This is only present when the result is a postal code that contains multiple localities.
52 53 54 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 52 def postcode_localities @postcode_localities end |
#types ⇒ Array[String]
The types[] array indicates the type of the returned result. This array contains a set of zero or more tags identifying the type of feature returned in the result. For example, a geocode of “Chicago” returns “locality” which indicates that “Chicago” is a city, and also returns “political” which indicates it is a political entity.
46 47 48 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 46 def types @types end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 112 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 address_components = nil unless hash['address_components'].nil? address_components = [] hash['address_components'].each do |structure| address_components << (AddressComponent.from_hash(structure) if structure) end end address_components = nil unless hash.key?('address_components') formatted_address = hash.key?('formatted_address') ? hash['formatted_address'] : nil geometry = GeocodingGeometry.from_hash(hash['geometry']) if hash['geometry'] place_id = hash.key?('place_id') ? hash['place_id'] : nil types = hash.key?('types') ? hash['types'] : nil plus_code = PlusCode.from_hash(hash['plus_code']) if hash['plus_code'] postcode_localities = hash.key?('postcode_localities') ? hash['postcode_localities'] : SKIP partial_match = hash.key?('partial_match') ? hash['partial_match'] : SKIP # 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. GeocodingResult.new(address_components: address_components, formatted_address: formatted_address, geometry: geometry, place_id: place_id, types: types, plus_code: plus_code, postcode_localities: postcode_localities, partial_match: partial_match, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 66 def self.names @_hash = {} if @_hash.nil? @_hash['address_components'] = 'address_components' @_hash['formatted_address'] = 'formatted_address' @_hash['geometry'] = 'geometry' @_hash['place_id'] = 'place_id' @_hash['plus_code'] = 'plus_code' @_hash['types'] = 'types' @_hash['postcode_localities'] = 'postcode_localities' @_hash['partial_match'] = 'partial_match' @_hash end |
.nullables ⇒ Object
An array for nullable fields
89 90 91 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 89 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
80 81 82 83 84 85 86 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 80 def self.optionals %w[ plus_code postcode_localities partial_match ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
165 166 167 168 169 170 171 172 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 165 def inspect class_name = self.class.name.split('::').last "<#{class_name} address_components: #{@address_components.inspect}, formatted_address:"\ " #{@formatted_address.inspect}, geometry: #{@geometry.inspect}, place_id:"\ " #{@place_id.inspect}, plus_code: #{@plus_code.inspect}, types: #{@types.inspect},"\ " postcode_localities: #{@postcode_localities.inspect}, partial_match:"\ " #{@partial_match.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
156 157 158 159 160 161 162 |
# File 'lib/google_maps_platform/models/geocoding_result.rb', line 156 def to_s class_name = self.class.name.split('::').last "<#{class_name} address_components: #{@address_components}, formatted_address:"\ " #{@formatted_address}, geometry: #{@geometry}, place_id: #{@place_id}, plus_code:"\ " #{@plus_code}, types: #{@types}, postcode_localities: #{@postcode_localities},"\ " partial_match: #{@partial_match}, additional_properties: #{@additional_properties}>" end |