class TimestampMaker::TimeZoneLookupers::GeoName
Attributes
username[RW]
Public Class Methods
new(username:)
click to toggle source
# File lib/timestamp_maker/time_zone_lookupers/geo_name.rb, line 14 def initialize(username:) @username = username end
Public Instance Methods
lookup(latitude:, longitude:)
click to toggle source
# File lib/timestamp_maker/time_zone_lookupers/geo_name.rb, line 18 def lookup(latitude:, longitude:) query = URI.encode_www_form( [['lat', latitude], ['lng', longitude], ['username', username]] ) response = Net::HTTP.get_response(URI.parse("#{ENDPOINT}?#{query}")) raise "Got HTTP status code: #{response.code}" unless response.is_a?(Net::HTTPSuccess) parsed = JSON.parse(response.body) parsed['timezoneId'] end