Ruby Library
This is a Ruby library that enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code and weather that any IP address or hostname originates from. 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.
IP2Location Ruby Library (996.27 kB)
Version: 5.0.0
Installation
- Download IP2Location C library at here.
- Decompress C library.
tar ip2location-c-x.x.x.tar.gz - Download and decompress Ruby library.
tar ip2location-ruby-x.x.x.tar.gz - Get into working directory.
cd ip2location-ruby-x.x.x - Generate compilation files.
ruby extconf.rb --with-libIP2Location-lib=../ip2location-c-x.x.x/libIP2Location --with-includeIP2Location-include=../ip2location-c.x.x.x/libIP2Location - Start compilation.
make
*For MacOS X:
- Download IP2Location C library at here.
- Decompress C library.
tar ip2location-c-x.x.x.tar.gz - cd C-IP2Location-<version>/libIP2Location
- export CFLAGS=-I/usr/include/malloc
- gcc -arch i386 -arch x86_64 -arch ppc -c IP2Location.c iMath/imath.c
- gcc -arch i386 -arch x86_64 -arch ppc -dynamiclib -current_version 1.0 -o /usr/local/lib/libIP2Location.dylib IP2Location.o imath.o
- Download and decompress Python library.
tar ip2location-python-x.x.x.tar.gz - cd <path>/ip2location-ruby-<version>
- ruby extconf.rb
- make
Sample Codes
require 'IP2Location'
IP2LocObj = IP2Location.new()
IP2LocObj.open("data/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-SAMPLE.BIN")
rec = IP2LocObj.get_all("19.5.10.1")
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
puts rec.mcc
puts rec.mnc
puts rec.mobilebrand
puts rec.elevation
puts rec.usagetype
Sample Database (BIN)
Evaluation version of the database file having limited range of IP address information. You can query all IP addresses from 0.0.0.0 to 99.255.255.255 only.
- IP2Location™ DB1 Sample BIN database (308.92 kB)
- IP2Location™ DB2 Sample BIN database (38.45 MB)
- IP2Location™ DB3 Sample BIN database (10.75 MB)
- IP2Location™ DB4 Sample BIN database (43.54 MB)
- IP2Location™ DB5 Sample BIN database (16.86 MB)
- IP2Location™ DB6 Sample BIN database (50.08 MB)
- IP2Location™ DB7 Sample BIN database (48.64 MB)
- IP2Location™ DB8 Sample BIN database (55.54 MB)
- IP2Location™ DB9 Sample BIN database (18.88 MB)
- IP2Location™ DB10 Sample BIN database (58.38 MB)
- IP2Location™ DB11 Sample BIN database (19.27 MB)
- IP2Location™ DB12 Sample BIN database (58.77 MB)
- IP2Location™ DB13 Sample BIN database (17.80 MB)
- IP2Location™ DB14 Sample BIN database (59.42 MB)
- IP2Location™ DB15 Sample BIN database (20.60 MB)
- IP2Location™ DB16 Sample BIN database (62.02 MB)
- IP2Location™ DB17 Sample BIN database (22.22 MB)
- IP2Location™ DB18 Sample BIN database (67.82 MB)
- IP2Location™ DB19 Sample BIN database (57.30 MB)
- IP2Location™ DB20 Sample BIN database (69.40 MB)
- IP2Location™ DB21 Sample BIN database (22.59 MB)
- IP2Location™ DB22 Sample BIN database (72.02 MB)
- IP2Location™ DB23 Sample BIN database (57.63 MB)
- IP2Location™ DB24 Sample BIN database (72.57 MB)
