class Timezone::Lookup::Basic
@abstract Subclass and override {#lookup} to implement
a custom Lookup class.
Attributes
config[R]
Public Class Methods
new(config)
click to toggle source
@param config [#protocol, url, request_handler] a configuration
object
# File lib/timezone/lookup/basic.rb, line 14 def initialize(config) if config.protocol.nil? raise(::Timezone::Error::InvalidConfig, 'missing protocol') end if config.url.nil? raise(::Timezone::Error::InvalidConfig, 'missing url') end config.uri ||= URI.parse("#{config.protocol}://#{config.url}") @config = config end
Public Instance Methods
client()
click to toggle source
Returns an instance of the request handler.
@return [#get] an instance of a request handler
# File lib/timezone/lookup/basic.rb, line 31 def client config.request_handler.new(config) end
lookup(_lat, _long)
click to toggle source
Returns a timezone name for a given lat, long pair.
@param lat [Double] latitude coordinate @param long [Double] longitude coordinate @return [String] the timezone name @return [nil] if the lat, long pair does not resolve to an
actual timezone
@raise [Timezone::Error::Base] if an error occurred while
while performing the lookup
# File lib/timezone/lookup/basic.rb, line 44 def lookup(_lat, _long) raise NoMethodError, 'lookup is not implemented' end