Sha256: 754348aaf6948b180073a55b2e5fb569ccf3fc00d13934152100e1044efa34c5

Contents?: true

Size: 550 Bytes

Versions: 4

Compression:

Stored size: 550 Bytes

Contents

require 'timezone/lookup/basic'
require 'timezone/error'

module Timezone
  module Lookup
    # @!visibility private
    class Test < ::Timezone::Lookup::Basic
      def initialize(_config)
        @stubs = {}
      end

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

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

      private

      def key(lat, long)
        "#{lat},#{long}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
timezone-1.0.0 lib/timezone/lookup/test.rb
timezone-0.99.2 lib/timezone/lookup/test.rb
timezone-0.99.1 lib/timezone/lookup/test.rb
timezone-0.99.0 lib/timezone/lookup/test.rb