Sha256: b2f8260a82f3011879577c1d39e85caf20a13301dcfb6ea8cd020fa096561a9c

Contents?: true

Size: 918 Bytes

Versions: 5

Compression:

Stored size: 918 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, _=nil)
        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

5 entries across 5 versions & 1 rubygems

Version Path
geokit-1.14.0 lib/geokit/geocoders/geobytes.rb
geokit-1.13.1 lib/geokit/geocoders/geobytes.rb
geokit-1.13.0 lib/geokit/geocoders/geobytes.rb
geokit-1.12.0 lib/geokit/geocoders/geobytes.rb
geokit-1.11.0 lib/geokit/geocoders/geobytes.rb