Class: Timezone::Lookup::Basic Abstract
- Inherits:
-
Object
- Object
- Timezone::Lookup::Basic
- Defined in:
- lib/timezone/lookup/basic.rb
Overview
This class is abstract.
Subclass and override #lookup to implement a custom Lookup class.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#client ⇒ #get
Returns an instance of the request handler.
-
#initialize(config) ⇒ Basic
constructor
A new instance of Basic.
-
#lookup(_lat, _long) ⇒ String?
Returns a timezone name for a given lat, long pair.
Constructor Details
#initialize(config) ⇒ Basic
Returns a new instance of Basic.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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 |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/timezone/lookup/basic.rb', line 10 def config @config end |
Instance Method Details
#client ⇒ #get
Returns an instance of the request handler.
31 32 33 |
# File 'lib/timezone/lookup/basic.rb', line 31 def client config.request_handler.new(config) end |
#lookup(_lat, _long) ⇒ String?
Returns a timezone name for a given lat, long pair.
44 45 46 |
# File 'lib/timezone/lookup/basic.rb', line 44 def lookup(_lat, _long) raise NoMethodError, 'lookup is not implemented' end |