Sha256: fd6a38d5c92a6d80c0af318897ceede0e456dbaa901c285a2069b28d4af9406b

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

module Geokit
  module Geocoders
    # Provides geocoding based upon an IP address.  The underlying web service is GeoSelect
    class GeobytesGeocoder < BaseIpGeocoder
      def self.do_geocode(ip)
        process :json, ip
      end

      def self.submit_url(ip)
        "http://getcitydetails.geobytes.com/GetCityDetails?fqcn=#{ip}"
      end

      def self.parse_json(json)
        loc = new_loc
        loc.city          = json["geobytescity"]
        loc.country_code  = json["geobytesinternet"]
        loc.full_address  = json["geobytesfqcn"]
        loc.lat           = json["geobyteslatitude"]
        loc.lng           = json["geobyteslongitude"]
        loc.state         = json["geobytescode"]
        loc.precision     = json["geobytescertainty"]
        loc.state_name    = json["geobytesregion"]
        loc.success       = !json["geobytescity"].empty?
        loc
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geokit-1.10.0 lib/geokit/geocoders/geobytes.rb