Class: GoogleMapsPlatform::PlaceAutocompletePrediction
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::PlaceAutocompletePrediction
- Defined in:
- lib/google_maps_platform/models/place_autocomplete_prediction.rb
Overview
PlaceAutocompletePrediction Model.
Instance Attribute Summary collapse
-
#description ⇒ String
Contains the human-readable name for the returned result.
-
#distance_meters ⇒ Integer
The straight-line distance in meters from the origin.
-
#matched_substrings ⇒ Array[PlaceAutocompleteMatchedSubstring]
A list of substrings that describe the location of the entered term in the prediction result text, so that the term can be highlighted if desired.
-
#place_id ⇒ String
A textual identifier that uniquely identifies a place.
-
#reference ⇒ String
See place_id.
-
#structured_formatting ⇒ PlaceAutocompleteStructuredFormat
See place_id.
-
#terms ⇒ Array[PlaceAutocompleteTerm]
Contains an array of terms identifying each section of the returned description (a section of the description is generally terminated with a comma).
-
#types ⇒ Array[String]
Contains an array of types that apply to this place.
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(description:, matched_substrings:, structured_formatting:, terms:, place_id: SKIP, reference: SKIP, types: SKIP, distance_meters: SKIP, additional_properties: nil) ⇒ PlaceAutocompletePrediction
constructor
A new instance of PlaceAutocompletePrediction.
-
#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(description:, matched_substrings:, structured_formatting:, terms:, place_id: SKIP, reference: SKIP, types: SKIP, distance_meters: SKIP, additional_properties: nil) ⇒ PlaceAutocompletePrediction
Returns a new instance of PlaceAutocompletePrediction.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 91 def initialize(description:, matched_substrings:, structured_formatting:, terms:, place_id: SKIP, reference: SKIP, types: SKIP, distance_meters: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @description = description @matched_substrings = matched_substrings @place_id = place_id unless place_id == SKIP @reference = reference unless reference == SKIP @structured_formatting = structured_formatting @terms = terms @types = types unless types == SKIP @distance_meters = distance_meters unless distance_meters == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#description ⇒ String
Contains the human-readable name for the returned result. For establishment results, this is usually the business name. This content is meant to be read as-is. Do not programmatically parse the formatted address.
17 18 19 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 17 def description @description end |
#distance_meters ⇒ Integer
The straight-line distance in meters from the origin. This field is only returned for requests made with an origin.
60 61 62 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 60 def distance_meters @distance_meters end |
#matched_substrings ⇒ Array[PlaceAutocompleteMatchedSubstring]
A list of substrings that describe the location of the entered term in the prediction result text, so that the term can be highlighted if desired.
22 23 24 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 22 def matched_substrings @matched_substrings end |
#place_id ⇒ String
A textual identifier that uniquely identifies a place. To retrieve information about the place, pass this identifier in the placeId field of a Places API request. For more information about place IDs, see the [Place IDs](developers.google.com/maps/documentation/places/web-service/p lace-id) overview.
30 31 32 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 30 def place_id @place_id end |
#reference ⇒ String
See place_id.
34 35 36 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 34 def reference @reference end |
#structured_formatting ⇒ PlaceAutocompleteStructuredFormat
See place_id.
38 39 40 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 38 def structured_formatting @structured_formatting end |
#terms ⇒ Array[PlaceAutocompleteTerm]
Contains an array of terms identifying each section of the returned description (a section of the description is generally terminated with a comma). Each entry in the array has a value field, containing the text of the term, and an offset field, defining the start position of this term in the description, measured in Unicode characters.
46 47 48 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 46 def terms @terms end |
#types ⇒ Array[String]
Contains an array of types that apply to this place. For example: ‘[ “political”, “locality” ]` or `[ “establishment”, “geocode”, “beauty_salon” ]`. The array can contain multiple values. Learn more about [Place types](developers.google.com/maps/documentation/places/web-service /supported_types).
55 56 57 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 55 def types @types end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
109 110 111 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 154 155 156 157 158 159 160 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 109 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. description = hash.key?('description') ? hash['description'] : nil # Parameter is an array, so we need to iterate through it matched_substrings = nil unless hash['matched_substrings'].nil? matched_substrings = [] hash['matched_substrings'].each do |structure| matched_substrings << (PlaceAutocompleteMatchedSubstring.from_hash(structure) if structure) end end matched_substrings = nil unless hash.key?('matched_substrings') if hash['structured_formatting'] structured_formatting = PlaceAutocompleteStructuredFormat.from_hash(hash['structured_formatting']) end # Parameter is an array, so we need to iterate through it terms = nil unless hash['terms'].nil? terms = [] hash['terms'].each do |structure| terms << (PlaceAutocompleteTerm.from_hash(structure) if structure) end end terms = nil unless hash.key?('terms') place_id = hash.key?('place_id') ? hash['place_id'] : SKIP reference = hash.key?('reference') ? hash['reference'] : SKIP types = hash.key?('types') ? hash['types'] : SKIP distance_meters = hash.key?('distance_meters') ? hash['distance_meters'] : 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. PlaceAutocompletePrediction.new(description: description, matched_substrings: matched_substrings, structured_formatting: structured_formatting, terms: terms, place_id: place_id, reference: reference, types: types, distance_meters: distance_meters, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 63 def self.names @_hash = {} if @_hash.nil? @_hash['description'] = 'description' @_hash['matched_substrings'] = 'matched_substrings' @_hash['place_id'] = 'place_id' @_hash['reference'] = 'reference' @_hash['structured_formatting'] = 'structured_formatting' @_hash['terms'] = 'terms' @_hash['types'] = 'types' @_hash['distance_meters'] = 'distance_meters' @_hash end |
.nullables ⇒ Object
An array for nullable fields
87 88 89 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 87 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
77 78 79 80 81 82 83 84 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 77 def self.optionals %w[ place_id reference types distance_meters ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
172 173 174 175 176 177 178 179 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 172 def inspect class_name = self.class.name.split('::').last "<#{class_name} description: #{@description.inspect}, matched_substrings:"\ " #{@matched_substrings.inspect}, place_id: #{@place_id.inspect}, reference:"\ " #{@reference.inspect}, structured_formatting: #{@structured_formatting.inspect}, terms:"\ " #{@terms.inspect}, types: #{@types.inspect}, distance_meters: #{@distance_meters.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
163 164 165 166 167 168 169 |
# File 'lib/google_maps_platform/models/place_autocomplete_prediction.rb', line 163 def to_s class_name = self.class.name.split('::').last "<#{class_name} description: #{@description}, matched_substrings: #{@matched_substrings},"\ " place_id: #{@place_id}, reference: #{@reference}, structured_formatting:"\ " #{@structured_formatting}, terms: #{@terms}, types: #{@types}, distance_meters:"\ " #{@distance_meters}, additional_properties: #{@additional_properties}>" end |