Sha256: 1a1e96fa68765c3a716c3bec526f50a2a2dcb2ac9bd582227af1a6012b60c85e

Contents?: true

Size: 994 Bytes

Versions: 3

Compression:

Stored size: 994 Bytes

Contents

require_relative 'weather_services/base'
require_relative 'weather_services/response'

module Barometer
  module WeatherService
    def self.services=(services)
      @@services = services
    end

    def self.services
      @@services ||= Utils::VersionedRegistration.new
    end

    def self.register(key, *args, &block)
      if block_given?
        services.register(key, *args, &block)
      elsif args.size > 0
        services.register(key, *args)
      else
        raise ArgumentError
      end
    end

    def self.source(key, version=nil)
      services.find(key, version) or raise NotFound
    end

    def self.new(*args)
      Base.new(*args)
    end

    class KeyRequired < StandardError; end
    class NotFound < StandardError; end
  end
end

require_relative 'weather_services/wunderground_v1'
require_relative 'weather_services/yahoo'
require_relative 'weather_services/weather_bug'
require_relative 'weather_services/noaa'
require_relative 'weather_services/forecast_io'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
barometer-0.9.2 lib/barometer/weather_service.rb
barometer-0.9.1 lib/barometer/weather_service.rb
barometer-0.9.0 lib/barometer/weather_service.rb