4 Weather Libraries for Ruby and Rails Developers

By Peter Cooper

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.