Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

4 Weather Libraries for Ruby and Rails Developers

By Peter Cooper / October 14, 2008

bit-of-weather.png

Want to retrieve weather conditions in your Ruby script / application? There are four great solutions: WeatherMan, RWeather, rubyweather, and the Yahoo Weather Ruby API.

RWeather

RWeather, by Carlos Kozuszko, is a Ruby wrapper for the Weather XML data feed from The Weather Channel's weather.com. Carlos has put together a basic tutorial / overview of the library's use. Currently it has two main features: searching for locations, and then retrieving the current weather for locations of your choice. It's a nice, simple library.

WeatherMan

WeatherMan, by Jared Pace, goes a little deeper than RWeather. Jared wanted to add the ability to retrieve forecasts to RWeather, but upon finding no easy way to integrate it with RWeather's structure, he decided to produce WeatherMan instead (also his first ever gem release!). Jared says:

WeatherMan implements most of the weather.com XML API. It it based in part on RWeather but adds some functionality and is structured slightly differently. With it you can search for locations, get current conditions and forecasts for a location, and access the promotional links that weather.com asks you to display when using the API.

WeatherMan requires the installation of the xml-simple gem beforehand, but otherwise generally appears to offer a much wider range of features than RWeather. Jared's example code samples are compelling in their power and simplicity.

rubyweather

rubyweather is a lot older than WeatherMan but offers some of the same functionality. As with RWeather and WeatherMan, it uses Weather.com's data. Full documentation is available at http://rubyweather.rubyforge.org/

Yahoo! Weather API

Want to get weather from a source that isn't weather.com (as with the three libraries above)? Yahoo! has an option. yahoo-weather provides an object-oriented interface to the Yahoo! Weather XML RSS feed. You can quickly install with gem install yahoo-weather and the code examples given within the official documentation will get you up and running in no time.

I find the simplicity of Yahoo's offering very attractive, and you don't need to be signed up or registered in any way - you can get going in as long as it takes to copy and paste some code!

Post supported by: ActionGear is a menu-bar app for task management on your Mac. It's lightweight, quick, and helps you get stuff done. Try it out for free.

Comments

  1. Matt Didcoe says:

    For Australians, there is also the BOMWeather gem that gets it's data from the Bureau of Meteorology system (via Curl).

    You can get it from GitHub here - http://github.com/benschwarz/bom-weather/tree/master

  2. Peter Cooper says:

    Thanks for that! I love that when I post roundups like this, there are always things I haven't seen before :)

  3. Jared Pace says:

    Thanks for the round up. If I would have known about rubyweather earlier I probably wouldn't have built WeatherMan. It was a great learning process though building a gem. I'm surprised I over looked it when I was searching for a gem and that no one mentioned the similarity to rubyweather yet.

    Thanks again.

  4. Carlos Kozuszko says:

    Thanks for the mention!

    The aim was to build the simplest thing that could work as a gem. I'm glad to know that it was somehow useful to Jared for builing his WeatherMan.

  5. Jim says:

    Among the four I felt yahoo weather provides a pure Ruby object-oriented interface.

Other Posts to Enjoy

Twitter Mentions