Sha256: 5df445655b3f7109d97986871f776d81d72a120b30e6cd1999f85680caf6e981
Contents?: true
Size: 935 Bytes
Versions: 3
Compression:
Stored size: 935 Bytes
Contents
module Geokit module Geocoders # Provides geocoding based upon an IP address. The underlying web service is # ipstack, old freegeoip.net class IpstackGeocoder < BaseIpGeocoder config :api_key private def self.do_geocode(ip, _options = nil) process :json, ip end def self.submit_url(ip) "http://api.ipstack.com/#{ip}?access_key=#{api_key}" end def self.parse_json(result) loc = new_loc return loc if result['success'] == false loc.city = result['city'] loc.state_code = result['region_code'] loc.state_name = result['region_name'] loc.zip = result['zip'] loc.lat = result['latitude'] loc.lng = result['longitude'] loc.country_code = result['country_code'] loc.country = result['country_name'] loc.success = !loc.country_code.nil? loc end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
geokit-1.14.0 | lib/geokit/geocoders/ipstack.rb |
geokit-1.13.1 | lib/geokit/geocoders/ipstack.rb |
geokit-1.13.0 | lib/geokit/geocoders/ipstack.rb |