MaxMind
Support My Account FAQ My Order
Support My Account FAQ My Order

Apache Module
C
C# Class
Java Class
MS COM Object
Pascal
Perl Module
PHP Module
Python Class
Ruby Module
VB.Net
Support Center


Ruby API

Download
Download from here.

Requirements
GeoIP C Library must be installed to run Ruby API.

Usage
Net::GeoIP::TYPE_DISK               >> access type constant
Net::GeoIP::TYPE_RAM                >> access type constant

g = Net::GeoIP.new([access_type])
g = Net::GeoIP.open(db_filename[, access_type])

g.country_code_by_addr('127.0.0.1')   >> 'US'
g.country_code_by_name('yahoo.com')   >> 'US'
g.country_code3_by_addr('127.0.0.1')  >> 'USA'
g.country_code3_by_name('yahoo.com')  >> 'USA'
g.country_name_by_addr('127.0.0.1')   >> 'United States'
g.country_name_by_name('yahoo.com')   >> 'United States'
g.country_id_by_addr('127.0.0.1')     >> 225
g.country_id_by_name('yahoo.com')     >> 225
g.region_by_addr('127.0.0.1')         >> ?? Can't test this
g.region_by_name('yahoo.com')         >> ?? Can't test this

g.database_info()                     >> Misc database info
g.update_database(your_key_here[,debug])  >> Updates your database

There is an updated net-geoip module with support for GeoIP City available from RubyForge (SVN checkout required). There is a patch available to add GeoIP ISP/Organization support.

Michal Safranek has contributed a geoipupdate alternative for automating the updates of GeoIP Country.

Credits
Thanks to Sean Chittenden for writing the GeoIP Ruby API.


MaxMind, GeoIP and related marks are registered trademarks of MaxMind, Inc.
Copyright © 2008 MaxMind, Inc. All Rights Reserved. Terms of use.