Class: Timezone::Lookup::Test

Inherits:
Basic
  • Object
show all
Defined in:
lib/timezone/lookup/test.rb

Instance Attribute Summary

Attributes inherited from Basic

#config

Instance Method Summary collapse

Methods inherited from Basic

#client

Constructor Details

#initialize(config) ⇒ Test

Returns a new instance of Test.



7
8
9
10
# File 'lib/timezone/lookup/test.rb', line 7

def initialize(config)
  @stubs = {}
  # Regular config w/ protocol and URL checks does not apply for stubs.
end

Instance Method Details

#lookup(lat, lng) ⇒ Object



16
17
18
19
20
# File 'lib/timezone/lookup/test.rb', line 16

def lookup(lat, lng)
  @stubs.fetch(key(lat, lng)) do
    raise ::Timezone::Error::Test, 'missing stub'
  end
end

#stub(lat, lng, timezone) ⇒ Object



12
13
14
# File 'lib/timezone/lookup/test.rb', line 12

def stub(lat, lng, timezone)
  @stubs[key(lat, lng)] = timezone
end