1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
require 'geocoder/results/base'
module Geocoder::Result
class Ip2locationLite < Base
def coordinates
[@data[:latitude], @data[:longitude]]
end
def city
@data[:city]
end
def state
@data[:region]
end
def state_code
"" # Not available in Maxmind's database
end
def country
@data[:country_long]
end
def country_code
@data[:country_short]
end
def postal_code
@data[:zipcode]
end
def self.response_attributes
%w[country_short country_long region latitude longitude isp
domain netspeed areacode iddcode timezone zipcode weatherstationname
weatherstationcode mcc mnc mobilebrand elevation usagetype addresstype
category district asn as]
end
response_attributes.each do |a|
define_method a do
@data[a] || ""
end
end
end
end
|