Class: Geokit::Geocoders::GeobytesGeocoder

Inherits:
BaseIpGeocoder show all
Defined in:
lib/geokit/geocoders/geobytes.rb

Overview

Provides geocoding based upon an IP address. The underlying web service is GeoSelect

Constant Summary

Constants inherited from BaseIpGeocoder

BaseIpGeocoder::NON_ROUTABLE_IP_RANGES

Class Method Summary collapse

Methods inherited from BaseIpGeocoder

ip?, private_ip_address?, process, valid_ip?

Methods inherited from Geocoder

geocode, reverse_geocode

Class Method Details

.do_geocode(ip, _ = nil) ⇒ Object



5
6
7
# File 'lib/geokit/geocoders/geobytes.rb', line 5

def self.do_geocode(ip, _=nil)
  process :json, ip
end

.parse_json(json) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/geokit/geocoders/geobytes.rb', line 13

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

.submit_url(ip) ⇒ Object



9
10
11
# File 'lib/geokit/geocoders/geobytes.rb', line 9

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