Talking to Plazes from Ruby

The code described here has been moved into Subversion.

I’ve been experimenting with Ruby of late, and decided it would be good practice to try and code up a Plazes “Where Am I?” application to learn more about the languages ins and outs.

The result is PlazesWhereAmIRuby-0.2.tar.gz. This is my first Ruby script (or whatever they’re called), so I can’t claim that this is anywhere near Ruby best practices. But it works. To use the script:

  • Get Ruby (here’s a place to start). Mac OS X users (post-Jaguar) can skip this step; you already have Ruby installed by default.
  • Download PlazesWhereAmIRuby-0.2.tar.gz.
  • tar -xzvf PlazesWhereAmIRuby-0.2.tar.gz
  • Edit the file PlazesWhereAmIRuby.rb and replace the ‘username’ and ‘password’ with your Plazes username and password.
  • ruby PlazesWhereAmIRuby.rb

The result will be something like this:

{“plazestate”=>”Prince Edward Island”, “username”=>”reinvented”, “plazelat”=>46.2361, “plazelon”=>-63.13, “plazecity”=>”Charlottetown”, “plazename”=>”Reinvented Office”, “plazeurl”=>””, “plazecountry”=>”CA”}

…which is simply a dump of the parameters returned from the Plazes server.

Update: I’ve created a more general-purpose module for Ruby that implements not only the WhereAmI API, but also the Launcher API.