Class: Geocoder::Result::Freegeoip

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/results/freegeoip.rb

Instance Attribute Summary

Attributes inherited from Base

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#coordinates, #initialize, #latitude, #longitude

Constructor Details

This class inherits a constructor from Geocoder::Result::Base

Class Method Details

.response_attributesObject



26
27
28
29
# File 'lib/geocoder/results/freegeoip.rb', line 26

def self.response_attributes
  %w[city region_code region_name metrocode
    zipcode country_name country_code ip]
end

Instance Method Details

#address(format = :full) ⇒ Object



6
7
8
# File 'lib/geocoder/results/freegeoip.rb', line 6

def address(format = :full)
  "#{city}#{', ' + region_code unless region_code == ''} #{postal_code}, #{country}"
end

#cityObject



10
11
12
# File 'lib/geocoder/results/freegeoip.rb', line 10

def city
  @data['city']
end

#countryObject



14
15
16
# File 'lib/geocoder/results/freegeoip.rb', line 14

def country
  @data['country_name']
end

#country_codeObject



18
19
20
# File 'lib/geocoder/results/freegeoip.rb', line 18

def country_code
  @data['country_code']
end

#postal_codeObject



22
23
24
# File 'lib/geocoder/results/freegeoip.rb', line 22

def postal_code
  @data['zipcode']
end