Sha256: fc1024a9046b52553dae396d7b0a5891032bcbfc6e87401fab11fbba784d9231
Contents?: true
Size: 784 Bytes
Versions: 1
Compression:
Stored size: 784 Bytes
Contents
module Geokit module Geocoders # Provides geocoding based upon an IP address. The underlying web service is freegeoip.net class FreeGeoIpGeocoder < BaseIpGeocoder private def self.do_geocode(ip) process :xml, ip end def self.submit_url(ip) "http://freegeoip.net/xml/#{ip}" end XML_MAPPINGS = { city: 'City', state: 'RegionCode', zip: 'ZipCode', country_code: 'CountryCode', lat: 'Latitude', lng: 'Longitude' } def self.parse_xml(xml) loc = new_loc set_mappings(loc, xml.elements['Response'], XML_MAPPINGS) loc.success = !!loc.city && !loc.city.empty? loc end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geokit-1.9.0 | lib/geokit/geocoders/free_geo_ip.rb |