forecast ======== > Forecast Multi-API-Wrapper with unified model and integrated caching ## API Support * Open Weather Map * Yahoo RSS * Forecast.io * Wunderground ## Fetch #### Forecast.current( latitude, longitude ) Get the current weather for a specified location ```ruby forecast = Forecast.current(54.9999, 9.534) ``` #### Forecast.hourly( latitude, longitude ) Get hourly forecasts for a specified location ```ruby forecasts = Forecast.hourly(54.9999, 9.534) ``` #### Forecast.daily( latitude, longitude ) Get daily forecasts for a specified location ```ruby forecasts = Forecast.daily(54.9999, 9.534) ``` ### Collections #### ForecastCollection.select_time( date ) Fetches forecast for the specified date from a collection. ```ruby forecast = Forecast.daily(54.9999, 9.534).select_time(Time.now + (24 * 60 * 60) * 2) ``` ## Model
Name | Description |
---|---|
condition | Condition string identifier. |
time | DateTime of the forecast |
icon | Returns icon identifier |
latitude | Location coordinate latitude |
longitude | Location coordinate longitude |
temperature | Temperature |
temperature_min | Minimum Temperature |
temperature_max | Maximum Temperature |
Code | Name |
---|---|
100 | Clear |
200 | Partly Cloudy |
210 | Cloudy |
220 | Mostly Cloudy |
300 | Light Rain |
310 | Rain |
320 | Heavy Rain |
400 | Light Snow |
410 | Snow |
500 | Storm |
The weather of tomorrow in New York: <%= forecast(41.145495, -73.994901, Time.now + 60*60*24) %>
``` #### Example Configuration ```ruby # config/initializers/forecast.rb Forecast::configure do |config| config.config_file = Rails.root.to_s + "/config/forecast.yml" config.cache = { expire: 1 * 60 * 60, url: "redis://xxx/" } end ``` ```yml # config/forecast.yml forecast: temperature: celsius theme: custom_theme themes: custom_theme: Clear: 'icon-clear' Light Rain: 'icon-rain' Rain: 'icon-rain' Heavy Rain: 'icon-rain' Partly Cloudy: 'icon-cloudy' Cloudy: 'icon-cloudy' Mostly Cloudy: 'icon-cloudy' Light Snow: 'icon-snow' Snow: 'icon-snow' Heavy Snow: 'icon-snow' Thunderstorm: 'icon-thunderstorm' ``` ## Command Line Interface ```cli Usage: forecast COMMAND [OPTIONS] Commands current: get current weather [default] daily: get daily forecasts hourly: get hourly forecasts Options -l, --location LAT,LNG Location [required] -p, --provider PROVIDER Supported API Providers: forecast_io, open_weather_map, wunderground, yahoo -a, --api_key API_KEY Apply an api key if neccessary -s, --scale SCALE Scale: one of celsius, fahrenheit or kelvin -h, --help Displays Help ``` ## Run Tests To run the tests execute `rspec spec` from the command line ```cli rspec spec ``` ## Changelog See the [Changelog](CHANGELOG.md) for recent enhancements, bugfixes and deprecations.