# File lib/geo_ip.rb, line 38
    def geolocation ip, options={}
      @precision = options[:precision] || :city
      @timezone  = options[:timezone]  || false
      raise 'API key must be set first: GeoIp.api_key = \'YOURKEY\'' if self.api_key.nil?
      raise 'Invalid IP address' unless ip.to_s =~ IPV4_REGEXP
      raise 'Invalid precision'  unless [:country, :city].include?(@precision)
      raise 'Invalid timezone'   unless [true, false].include?(@timezone)
      url = "#{SERVICE_URL}#{@precision == :city || @timezone ? CITY_API : COUNTRY_API}?key=#{api_key}&ip=#{ip}&format=json&timezone=#{@timezone}"
      parsed_response = JSON.parse RestClient::Request.execute(:method => :get, :url => url, :timeout => self.timeout)
      convert_keys parsed_response
    end