Class: Autometal::Geoip::City

Inherits:
Package
  • Object
show all
Defined in:
lib/geoip/city.rb

Overview

GeoLiteCity database extension

provides Country, City, Latitude and Longitude information.

Instance Attribute Summary collapse

Attributes inherited from Package

#version

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Package

#initialize, installed?, #lookup

Constructor Details

This class inherits a constructor from Autometal::Geoip::Package

Instance Attribute Details

#cityObject

Returns the value of attribute city.



8
9
10
# File 'lib/geoip/city.rb', line 8

def city
  @city
end

#countryObject

Returns the value of attribute country.



8
9
10
# File 'lib/geoip/city.rb', line 8

def country
  @country
end

#countyObject

Returns the value of attribute county.



8
9
10
# File 'lib/geoip/city.rb', line 8

def county
  @county
end

#latObject

Returns the value of attribute lat.



8
9
10
# File 'lib/geoip/city.rb', line 8

def lat
  @lat
end

#lngObject

Returns the value of attribute lng.



8
9
10
# File 'lib/geoip/city.rb', line 8

def lng
  @lng
end

Class Method Details

.data_fileObject



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

#latlngObject Also known as: latlon



9
10
11
# File 'lib/geoip/city.rb', line 9

def latlng
  [self.lat,self.lng]
end

#process_responseObject



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