class Locotimezone::Geolocate

Attributes

address[R]

Public Class Methods

new(address) click to toggle source
# File lib/locotimezone/geolocate.rb, line 5
def initialize(address)
  @address = address
end

Public Instance Methods

call() click to toggle source
# File lib/locotimezone/geolocate.rb, line 9
def call
  ResultsFormatter.build_geolocation_hash_for geolocation
rescue OpenURI::HTTPError => e
  ErrorLogger.stdout_log_for(e, severity: :error)
  {}
end

Private Instance Methods

geolocation() click to toggle source
# File lib/locotimezone/geolocate.rb, line 18
def geolocation
  open(geolocation_query_url) { |f| JSON.parse f.read }
end
geolocation_query_url() click to toggle source
# File lib/locotimezone/geolocate.rb, line 22
def geolocation_query_url
  "https://maps.googleapis.com/maps/api/geocode/json?address="\
  "#{address}&key=#{Locotimezone.configuration.google_api_key}"
end