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.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/timezone/lookup/basic.rb', line 12 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 = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/timezone/lookup/basic.rb', line 8 def config @config end |
Instance Method Details
#client ⇒ #get
Returns an instance of the request handler.
27 28 29 30 31 32 33 34 35 |
# File 'lib/timezone/lookup/basic.rb', line 27 def client # TODO: Remove http_client once on 1.0.0 @client ||= if !config.request_handler.nil? config.request_handler.new(config) else config.http_client.new(config.protocol, config.url) end end |
#lookup(_lat, _long) ⇒ String?
Returns a timezone name for a given lat, long pair.
46 47 48 |
# File 'lib/timezone/lookup/basic.rb', line 46 def lookup(_lat, _long) raise NoMethodError, 'lookup is not implemented' end |