Class: GeoLocator

Inherits:
AsyncResolverWithCache show all
Defined in:
lib/GeoLocator.rb

Instance Attribute Summary

Attributes inherited from AsyncResolverWithCache

#enabled

Instance Method Summary collapse

Methods inherited from AsyncResolverWithCache

#cacheSize, #expireInMinutes, #flushQueue, #queueSize, #resolve, #stopAndSave

Constructor Details

#initializeGeoLocator

Returns a new instance of GeoLocator.



72
73
74
75
76
# File 'lib/GeoLocator.rb', line 72

def initialize
  super('GeoLocatorCache',
      $globals.getSetting('GeolocTimeout') * 60 * 60 * 24, 2)
  @enabled = $globals.getSetting('Geolocator')
end

Instance Method Details

#city(ip) ⇒ Object



86
87
88
# File 'lib/GeoLocator.rb', line 86

def city(ip)
  (rec = resolve(ip)) ? rec.city : nil
end

#country(ip) ⇒ Object



82
83
84
# File 'lib/GeoLocator.rb', line 82

def country(ip)
  (rec = resolve(ip)) ? rec.country : nil
end

#newRecordObject



78
79
80
# File 'lib/GeoLocator.rb', line 78

def newRecord
  GeoLocatorRecord.new
end