DaniWeb IT Discussion Community

Code Snippets (http://www.daniweb.com/code/)
-   ruby (http://www.daniweb.com/code/ruby.html)
-   -   IP2Location Ruby Library (http://www.daniweb.com/code/snippet607.html)

IP2Location ruby syntax
Dec 3rd, 2006
IP2Location is a Ruby library that enables the user to find the country, region, city, coordinates, zip code, ISP and domain name 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.

  1. <%
  2.  
  3. require 'IP2Location'
  4.  
  5. IP2LocObj = IP2Location.new()
  6. IP2LocObj.open("data/IP-COUNTRY-SAMPLE.BIN")
  7. rec = IP2LocObj.get_all("19.5.10.1")
  8. puts rec.country_short
  9. puts rec.country_long
  10. puts rec.city
  11. puts rec.region
  12. puts rec.isp
  13. puts rec.latitude
  14. puts rec.longitude
  15. puts rec.domain
  16. puts rec.zipcode
  17. puts rec.timezone
  18. puts rec.netspeed
  19.  
  20. %>