Class: Everlog::Inf::Api::Wunderground
- Inherits:
-
Everlog::Inf::Api
- Object
- Everlog::Inf::Api
- Everlog::Inf::Api::Wunderground
- Defined in:
- lib/everlog/inf/api/wunderground.rb
Defined Under Namespace
Classes: InfrastructureWeatherError
Instance Method Summary collapse
- #client ⇒ Object
-
#initialize(config) ⇒ Wunderground
constructor
A new instance of Wunderground.
- #yesterday(place) ⇒ Object
Constructor Details
#initialize(config) ⇒ Wunderground
Returns a new instance of Wunderground.
5 6 7 8 |
# File 'lib/everlog/inf/api/wunderground.rb', line 5 def initialize config super(config) @cache = Inf::Cache::File::Wunderground.new end |
Instance Method Details
#client ⇒ Object
10 11 12 |
# File 'lib/everlog/inf/api/wunderground.rb', line 10 def client @client ||= ::Wunderground.new(@config.access_token, throws_exceptions: true) end |
#yesterday(place) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/everlog/inf/api/wunderground.rb', line 14 def yesterday place @cache.delete((Date.today - 2).to_s) @cache.get_and_save((Date.today - 1).to_s, { place: place, client: client}) do |args| args[:client].yesterday_for(args[:place])['history'] end rescue => e raise InfrastructureWeatherError, "yesterday error / #{e.message}" end |