Class: Geocoder::Result::Base
- Inherits:
-
Object
- Object
- Geocoder::Result::Base
show all
- Defined in:
- lib/geocoder/results/base.rb
Direct Known Subclasses
Amap, Baidu, BaiduIp, Bing, Esri, Freegeoip, GeocoderCa, GeocoderUs, Geocodio, Geoip2, Google, Here, Mapquest, Maxmind, MaxmindLocal, Nominatim, Okf, Opencagedata, Ovi, Pointpin, PostcodeAnywhereUk, SmartyStreets, Telize, Test, Yahoo, Yandex
Instance Attribute Summary collapse
-
#cache_hit ⇒ Object
true if result came from cache, false if from request to geocoding service; nil if cache is not configured.
-
#data ⇒ Object
data (hash) fetched from geocoding service.
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Base
Takes a hash of data from a parsed geocoding service response.
15
16
17
18
|
# File 'lib/geocoder/results/base.rb', line 15
def initialize(data)
@data = data
@cache_hit = nil
end
|
Instance Attribute Details
#cache_hit ⇒ Object
true if result came from cache, false if from request to geocoding service; nil if cache is not configured
10
11
12
|
# File 'lib/geocoder/results/base.rb', line 10
def cache_hit
@cache_hit
end
|
#data ⇒ Object
data (hash) fetched from geocoding service
6
7
8
|
# File 'lib/geocoder/results/base.rb', line 6
def data
@data
end
|
Instance Method Details
#address(format = :full) ⇒ Object
A string in the given format.
23
24
25
|
# File 'lib/geocoder/results/base.rb', line 23
def address(format = :full)
fail
end
|
#coordinates ⇒ Object
A two-element array: [lat, lon].
30
31
32
|
# File 'lib/geocoder/results/base.rb', line 30
def coordinates
[@data['latitude'].to_f, @data['longitude'].to_f]
end
|
#country ⇒ Object
58
59
60
|
# File 'lib/geocoder/results/base.rb', line 58
def country
fail
end
|
#country_code ⇒ Object
62
63
64
|
# File 'lib/geocoder/results/base.rb', line 62
def country_code
fail
end
|
#latitude ⇒ Object
34
35
36
|
# File 'lib/geocoder/results/base.rb', line 34
def latitude
coordinates[0]
end
|
#longitude ⇒ Object
38
39
40
|
# File 'lib/geocoder/results/base.rb', line 38
def longitude
coordinates[1]
end
|
#province ⇒ Object
46
47
48
|
# File 'lib/geocoder/results/base.rb', line 46
def province
state
end
|
#province_code ⇒ Object
54
55
56
|
# File 'lib/geocoder/results/base.rb', line 54
def province_code
state_code
end
|
#state ⇒ Object
42
43
44
|
# File 'lib/geocoder/results/base.rb', line 42
def state
fail
end
|
#state_code ⇒ Object
50
51
52
|
# File 'lib/geocoder/results/base.rb', line 50
def state_code
fail
end
|