A Few Ruby Experiences

I flew out to Seattle for a .NET 2.0 compatibility session. Unlike last time I was here (summer of 2001), it's rainy, so I've finally got to experience the true Seattle experience. Most of the flight out, I was playing with writing a simple aggregator in Ruby; my first experience with a "real" Ruby app. Notwithstanding the problems of working on a laptop when the person in front of you has their seat leaned ALL THE WAY BACK, it was fairly painless, with the wxRuby samples and documentation, I was able to set up my GUI over the course of a couple hours. I've been working on hooking this app to the network this evening. The networking aspects have been less rewarding; progress has been hit or miss. The latest stumbling block is a syntax error reported on the print response.body line from the sample below; syntactically, it looks OK to me. I suspect that there's some other state that's screwed up and the interpreter is simply mis-reporting the error.

require 'net/http'
require 'rexml'
http = Net::HTTP.start('www.newsgator.com')
req = Net::HTTP::Get.new('/')
http.request(req) { | resp | locationsLoaded(resp) }

def locationsLoaded(response) {
  print response.body
}

later No, now that I've got some sleep, I realize that function definitions don't take blocks. This is going to be an ongoing problem with me and Ruby, def...end versus block syntax.

— Gordon Weakliem at permanent link