Yr makes it easy to get weather forecast from Yr.no.
Add this line to your application's Gemfile:
gem 'yr'
And then execute:
$ bundle
Or install it yourself as:
$ gem install yr
oslo = Yr::Place.find "Oslo"
oslo.forecast.days.each do |day|
p day.name
p day.date
p day.temperature.value
end
If you are using Rails, all the weather symbols are included in the assets
pipeline, both svg and png formats. This means you can do something like this
if you want to display an icon <%= image_tag day.symbol.svg %>
or
<%= image_tag day.symbol.png %>
.
PNG files are included in several sizes, which you can specify like this
<%= image_tag day.symbol.png(size: 100) %>
.
The supported png sizes are:
- 30px
- 38px
- 48px (default)
- 100px
- 200px
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Hyper made this. We're a digital communications agency with a passion for good code, and if you're using this library we probably want to hire you.
Also thanks to https://github.com/Hakon/yr_api for inspiration and some code.
Yr is available under the MIT license. See the LICENSE file for more info.