module SimpleGeolocator
noinspection RubyTooManyInstanceVariablesInspection
Constants
- URL_FORMAT
Public Instance Methods
get(ip)
click to toggle source
Gets the full response. From here, all the data related to the IP can be accessed. Caches the result in order to
prevent reaching the rate limit.
@param ip [String] The IP to get data for. @return [IPAPIResponse] The full parsed response object.
# File lib/simple_geolocator.rb, line 17 def get(ip) return @cache[ip] if @cache.key?(ip) url = format(URL_FORMAT, ip) response = Curl.get(url).body_str ipapi = SimpleGeolocator::IPAPIResponse.new(Oj.load(response)) @cache[ip] = ipapi end