Class GeoIp
In: lib/geo_ip.rb
Parent: Object

Methods

Constants

SERVICE_URL = 'http://api.ipinfodb.com/v3/ip-'
CITY_API = 'city'
COUNTRY_API = 'country'
IPV4_REGEXP = /\A(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)(?:\.(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)){3}\z/

Public Class methods

Retreive the remote location of a given ip address.

It takes two optional arguments:

  • preceision: can either be +:city+ (default) or +:country+
  • timezone: can either be false (default) or true

Example:

  GeoIp.geolocation('209.85.227.104', {:precision => :city, :timezone => true})

[Validate]