Sha256: fdb6ff08d8916d6d7da6ea35bdcd7d1323f8bf923d62255e3bd9485667d7b870
Contents?: true
Size: 824 Bytes
Versions: 4
Compression:
Stored size: 824 Bytes
Contents
module Geokit module Geocoders # Provides geocoding based upon an IP address. The underlying web service is geoplugin.net class GeoPluginGeocoder < BaseIpGeocoder private def self.do_geocode(ip) process :xml, ip end def self.submit_url(ip) "http://www.geoplugin.net/xml.gp?ip=#{ip}" end XML_MAPPINGS = { :city => 'geoplugin_city', :state => 'geoplugin_region', :country_code => 'geoplugin_countryCode', :lat => 'geoplugin_latitude', :lng => 'geoplugin_longitude' } def self.parse_xml(xml) loc = new_loc set_mappings(loc, xml.elements['geoPlugin'], XML_MAPPINGS) loc.success = !!loc.city && !loc.city.empty? loc end end end end
Version data entries
4 entries across 4 versions & 1 rubygems