Author
The ip2country library for Ruby was written by Matthew Harris with many contributions by the Ruby community.
Synopsis
This library provides a “IP to country” lookup mechanism for checking remote IP addresses against WebHosting.Info ip-to-country database to determine the IP’s regional origin.
Usage
require 'rubygems'
require 'ip2country'
ip2c = IP2Country.new
ip = '58.77.42.37'
if country = ip2c.lookup(ip)
puts "#{ip} belongs is located in: #{country.name} (#{country.cc})"
else
puts "The region for #{ip} could not be determined."
end