pmuellr is Patrick Mueller

other pmuellr thangs: home page, twitter, flickr, github

Friday, December 22, 2006

taking the Ruby plunge

'Ruby Falls Barn' by Brent Moore

I've finally taken the Ruby plunge. It's taken a while. My buddy Chris Grindstaff recommended I look at it years ago. I had heard of it, and it sounded interesting, but coming from Chris, I took a closer look. Started following it from afar. Eventually bought the book. Still didn't really do anything.

Finally, as I have been posting flickr pix in my blog entries, and copy/pasting the html into new entries, it was time to automate, and thus getf4b was born. Simple command line program, and thus easy to integrate into TextMate and Eclipse.

(Quick aside: I edit all my blog posts in .html files using TextMate, then paste into roller when I'm all done.)

So, Ruby. I'm an old smalltalker, so I don't need much convincing on the gorgeousness of the language. I am a little suprised there's not much interest from the old OTI crowd in Ruby. They'll come around.

The little program I wrote uses a Ruby gem named 'flickr' to do all the flickr API work, but there are some issues. Check the code and you'll see how I had to hack the photo URLs a bit. I needed to figure out how to get program arguments, the name and location of the program being invoked, some basic string parsing, and how to do 'here doc'. Everything else was pretty natural.

Actually, the hardest thing was figuring out to 'require' a gem. It helps to require 'rubygems' first, and then use require_gem instead of require for a gem. The doc didn't really make that clear.

More later, I'm sure.

Photo 'Ruby Falls Barn' with a nice CC license, by Brent Moore. Found using the Flickr's Create Commons Search.

No comments: