IP2Location Ruby Library
Join the DZone community and get the full member experience.Join For Free
IP2Location Ruby Library enables the user to find the Country, Region, City, Latitude, Longitude, ZIP code, Time zone, ISP, Domain name, Connection type, Area code and Weather station code of the location that any IP address or hostname originates from. This API is meant to allow easy integration between your program written in Ruby and the IP2Location Binary (.BIN) data file. It has been optimized for speed and memory utilization. Developers can use the API to query all IP2Locationâ„¢ binary databases for applications written in C or supporting static/dynamic library. Get more geolocation information at http://www.ip2location.com and download the source code at http://www.ip2location.com/ruby.aspx.
require 'IP2Location' IP2LocObj = IP2Location.new() IP2LocObj.open("data/IP-COUNTRY-SAMPLE.BIN") rec = IP2LocObj.get_all("188.8.131.52") puts rec.country_short puts rec.country_long puts rec.city puts rec.region puts rec.isp puts rec.latitude puts rec.longitude puts rec.domain puts rec.zipcode puts rec.timezone puts rec.netspeed puts rec.iddcode puts rec.areacode puts rec.weatherstationcode puts rec.weatherstationname
Opinions expressed by DZone contributors are their own.