Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Geolocator
- DB = Rails.root.join('db/GeoIP.dat')
- def initialize
- @geo_ip = GeoIP.new(DB)
- end
- def locate(ip)
- _, _, _, country_code, _, _, _ = @geo_ip.country(ip)
- (country_code == "--") ? nil : country_code
- end
- def self.locate(ip)
- self.new.locate(ip)
- end
- end
Add Comment
Please, Sign In to add comment