Class: Geocoder::Result::Ipgeolocation
- Defined in:
- lib/geocoder/results/ipgeolocation.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #address(format = :full) ⇒ Object
- #coordinates ⇒ Object
- #country ⇒ Object
- #country_code ⇒ Object
- #postal_code ⇒ Object
- #state ⇒ Object
- #state_code ⇒ Object
Methods inherited from Base
#initialize, #latitude, #longitude, #province, #province_code
Constructor Details
This class inherits a constructor from Geocoder::Result::Base
Class Method Details
.response_attributes ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/geocoder/results/ipgeolocation.rb', line 34 def self.response_attributes [ ['ip', ''], ['hostname', ''], ['continent_code', ''], ['continent_name', ''], ['country_code2', ''], ['country_code3', ''], ['country_name', ''], ['country_capital',''], ['district',''], ['state_prov',''], ['city', ''], ['zipcode', ''], ['time_zone', {}], ['currency', {}] ] end |
Instance Method Details
#address(format = :full) ⇒ Object
10 11 12 |
# File 'lib/geocoder/results/ipgeolocation.rb', line 10 def address(format = :full) "#{city}, #{state} #{postal_code}, #{country_name}".sub(/^[ ,]*/, "") end |
#coordinates ⇒ Object
6 7 8 |
# File 'lib/geocoder/results/ipgeolocation.rb', line 6 def coordinates [@data['latitude'].to_f, @data['longitude'].to_f] end |
#country ⇒ Object
22 23 24 |
# File 'lib/geocoder/results/ipgeolocation.rb', line 22 def country @data['country_name'] end |
#country_code ⇒ Object
26 27 28 |
# File 'lib/geocoder/results/ipgeolocation.rb', line 26 def country_code @data['country_code2'] end |
#postal_code ⇒ Object
30 31 32 |
# File 'lib/geocoder/results/ipgeolocation.rb', line 30 def postal_code @data['zipcode'] end |
#state ⇒ Object
14 15 16 |
# File 'lib/geocoder/results/ipgeolocation.rb', line 14 def state @data['state_prov'] end |
#state_code ⇒ Object
18 19 20 |
# File 'lib/geocoder/results/ipgeolocation.rb', line 18 def state_code @data['state_prov'] end |