28 October 2006

My first Ruby program

I decided to learn Ruby and Rails — now I need to get books on both (damn that DHH and his contagious enthusiasm)

Below are some snippets from my first Ruby program: convert.rb. It is a CGI program, that converts PostScript, TeX, CWEB and a couple of other formats to PDF. It also converts .tar.gz, .tar.bz2 and other compressed files to .zip.

[Note: I wrote this program flipping back and forth between the PixAxe1 and a bunch of other online resources — so forgive me if it isn't in the spirit of Ruby.]

I was surprised at how easily and quickly I was able to develop the program

calling methods (those that don't take args and those that take a single arg) without parenthesis is quiet refreshing:
(Before this, looking at Ruby from the "outside", this convention was disturbing — "How do I pass a function to another function" — but I didn't encounter that problem with this program because it seems to me that you pass in closures (blocks) to other functions...)