Class: Autometal::Geoip::City
Overview
GeoLiteCity database extension
provides Country, City, Latitude and Longitude information.
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#county ⇒ Object
Returns the value of attribute county.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lng ⇒ Object
Returns the value of attribute lng.
Attributes inherited from Package
Class Method Summary collapse
Instance Method Summary collapse
- #latlng ⇒ Object (also: #latlon)
- #process_response ⇒ Object
Methods inherited from Package
#initialize, installed?, #lookup
Constructor Details
This class inherits a constructor from Autometal::Geoip::Package
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
8 9 10 |
# File 'lib/geoip/city.rb', line 8 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
8 9 10 |
# File 'lib/geoip/city.rb', line 8 def country @country end |
#county ⇒ Object
Returns the value of attribute county.
8 9 10 |
# File 'lib/geoip/city.rb', line 8 def county @county end |
#lat ⇒ Object
Returns the value of attribute lat.
8 9 10 |
# File 'lib/geoip/city.rb', line 8 def lat @lat end |
#lng ⇒ Object
Returns the value of attribute lng.
8 9 10 |
# File 'lib/geoip/city.rb', line 8 def lng @lng end |
Class Method Details
.data_file ⇒ Object
14 15 16 |
# File 'lib/geoip/city.rb', line 14 def self.data_file File.join(Geoip::DATA_FILE_PATH,"GeoLiteCity.dat") end |
Instance Method Details
#latlng ⇒ Object Also known as: latlon
9 10 11 |
# File 'lib/geoip/city.rb', line 9 def latlng [self.lat,self.lng] end |
#process_response ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/geoip/city.rb', line 18 def process_response ar = @response.split(", ") @version = ar[0] @country = ar[1].gsub("Rev 1: ","") @county = ar[2] @city = ar[3] @lat = ar[5].to_f @lng = ar[6].to_f end |