Class: NWS::GeocodingResult
- Inherits:
-
Object
- Object
- NWS::GeocodingResult
- Defined in:
- lib/nws/geocoder.rb
Overview
Represents a geocoding result with coordinates and metadata
Constant Summary collapse
- ATTRIBUTION =
Returns Attribution text required by ODbL license.
Geocoder::ATTRIBUTION
Instance Attribute Summary collapse
-
#display_name ⇒ String
readonly
Full display name of the location.
-
#from_cache ⇒ Boolean
readonly
Whether this result was retrieved from cache.
-
#latitude ⇒ Float
readonly
Latitude of the location.
-
#longitude ⇒ Float
readonly
Longitude of the location.
-
#place_type ⇒ String
readonly
Type of place (e.g., “city”, “administrative”).
Instance Method Summary collapse
-
#attribution ⇒ String
Get the required attribution text.
-
#from_cache? ⇒ Boolean
Check if this result was retrieved from cache.
-
#initialize(latitude:, longitude:, display_name:, place_type:, from_cache: false) ⇒ GeocodingResult
constructor
Initialize a new GeocodingResult.
-
#to_a ⇒ Array<Float>
Convert to array of [latitude, longitude].
-
#to_s ⇒ String
Get a formatted string representation.
Constructor Details
#initialize(latitude:, longitude:, display_name:, place_type:, from_cache: false) ⇒ GeocodingResult
Initialize a new GeocodingResult
240 241 242 243 244 245 246 |
# File 'lib/nws/geocoder.rb', line 240 def initialize(latitude:, longitude:, display_name:, place_type:, from_cache: false) @latitude = latitude @longitude = longitude @display_name = display_name @place_type = place_type @from_cache = from_cache end |
Instance Attribute Details
#display_name ⇒ String (readonly)
Returns Full display name of the location.
222 223 224 |
# File 'lib/nws/geocoder.rb', line 222 def display_name @display_name end |
#from_cache ⇒ Boolean (readonly)
Returns Whether this result was retrieved from cache.
228 229 230 |
# File 'lib/nws/geocoder.rb', line 228 def from_cache @from_cache end |
#latitude ⇒ Float (readonly)
Returns Latitude of the location.
216 217 218 |
# File 'lib/nws/geocoder.rb', line 216 def latitude @latitude end |
#longitude ⇒ Float (readonly)
Returns Longitude of the location.
219 220 221 |
# File 'lib/nws/geocoder.rb', line 219 def longitude @longitude end |
#place_type ⇒ String (readonly)
Returns Type of place (e.g., “city”, “administrative”).
225 226 227 |
# File 'lib/nws/geocoder.rb', line 225 def place_type @place_type end |
Instance Method Details
#attribution ⇒ String
Get the required attribution text
272 273 274 |
# File 'lib/nws/geocoder.rb', line 272 def attribution ATTRIBUTION end |
#from_cache? ⇒ Boolean
Check if this result was retrieved from cache
251 252 253 |
# File 'lib/nws/geocoder.rb', line 251 def from_cache? @from_cache end |
#to_a ⇒ Array<Float>
Convert to array of [latitude, longitude]
258 259 260 |
# File 'lib/nws/geocoder.rb', line 258 def to_a [latitude, longitude] end |
#to_s ⇒ String
Get a formatted string representation
265 266 267 |
# File 'lib/nws/geocoder.rb', line 265 def to_s "#{latitude}, #{longitude} (#{display_name})" end |