Sha256: 87f3e1ca2bb05fb32433137618f4254606aa636a4ec54a5708bd4eed2b07926c
Contents?: true
Size: 783 Bytes
Versions: 3
Compression:
Stored size: 783 Bytes
Contents
require_relative 'forecast_io/api' require_relative 'forecast_io/response' module Barometer module WeatherService class ForecastIo def self.call(query, config={}) ForecastIo.new(query, config).measure! end def initialize(query, config={}) @query = query @apikey = config[:keys][:api] if config[:keys] end def measure! validate_key! api = ForecastIo::Api.new(query, apikey) ForecastIo::Response.new.parse(api.get) end private attr_reader :query, :apikey def validate_key! unless apikey && !apikey.empty? raise KeyRequired end end end end end Barometer::WeatherService.register(:forecast_io, Barometer::WeatherService::ForecastIo)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
barometer-0.9.2 | lib/barometer/weather_services/forecast_io.rb |
barometer-0.9.1 | lib/barometer/weather_services/forecast_io.rb |
barometer-0.9.0 | lib/barometer/weather_services/forecast_io.rb |