Class: Geocoder::Result::Ipstack
- Defined in:
- lib/geocoder/results/ipstack.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #address(format = :full) ⇒ Object
- #country ⇒ Object
- #metro_code ⇒ Object
- #postal_code ⇒ Object
- #state ⇒ Object
- #state_code ⇒ Object
Methods inherited from Base
#coordinates, #country_code, #initialize, #latitude, #longitude, #province, #province_code
Constructor Details
This class inherits a constructor from Geocoder::Result::Base
Class Method Details
.response_attributes ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/geocoder/results/ipstack.rb', line 27 def self.response_attributes [ ['ip', ''], ['hostname', ''], ['continent_code', ''], ['continent_name', ''], ['country_code', ''], ['country_name', ''], ['region_code', ''], ['region_name', ''], ['city', ''], ['zip', ''], ['latitude', 0], ['longitude', 0], ['location', {}], ['time_zone', {}], ['currency', {}], ['connection', {}], ['security', {}], ] end |
Instance Method Details
#address(format = :full) ⇒ Object
6 7 8 9 |
# File 'lib/geocoder/results/ipstack.rb', line 6 def address(format = :full) s = region_code.empty? ? "" : ", #{region_code}" "#{city}#{s} #{zip}, #{country_name}".sub(/^[ ,]*/, "") end |
#country ⇒ Object
19 20 21 |
# File 'lib/geocoder/results/ipstack.rb', line 19 def country @data['country_name'] end |
#metro_code ⇒ Object
55 56 57 58 |
# File 'lib/geocoder/results/ipstack.rb', line 55 def metro_code Geocoder.log(:warn, "Ipstack does not implement `metro_code` in api results. Please discontinue use.") 0 # no longer implemented by ipstack end |
#postal_code ⇒ Object
23 24 25 |
# File 'lib/geocoder/results/ipstack.rb', line 23 def postal_code @data['zip'] || @data['zipcode'] || @data['zip_code'] end |
#state ⇒ Object
11 12 13 |
# File 'lib/geocoder/results/ipstack.rb', line 11 def state @data['region_name'] end |
#state_code ⇒ Object
15 16 17 |
# File 'lib/geocoder/results/ipstack.rb', line 15 def state_code @data['region_code'] end |