NEW: For a prettier blog interface, see the Wordpress version!


BCCheck out : Chat with :kuribas on (nil)
BXFile bug for ruby-default (2005.02.09)
BXFile bug for require (2005.02.09)
BXTrack down ri maintainer : planner (2005.02.09)
BXCheck out Ruby stuff : 2005.01.21:5 (nil)


1. Adventures with Ruby

This is my second day of Ruby, a programming language that is rather popular in Japan. I'm in love. It's now my second-favorite programming language. (Emacs Lisp is, of course, the first.)

Yesterday's script parsed schedule data and checked that monthly cost and day constraints were observed. Today I wanted to visualize the verified schedule.

At first I tried working with planner (formerly known as MrProject and not to be confused with PlannerMode). I wrote a Ruby program that converted my schedule.csv into XML, and planner loaded it successfully. However, I didn't think planner would let me do funky color coding. I thought about using etask, but ended up deciding to write something using libgd-ruby.

It was surprisingly easy to write a Gantt-like visualizer for the schedule and even easier to manipulate it once I had written it. For example, I could do silly things like

s.to_image((s.schedule.sort { |a,b| a.start <=> b.start }, 0, 2500, 1800, image) Sorted by start date

to see the tasks sorted by start date. Being a Lisp girl, I had no problems writing silly things like

s.to_image((s.schedule.collect { |x| x if x.person_id == '08-1' } - [ nil ]).sort { |a,b| a.start <=> b.start }, 0, 2500, 1800, image) but then I realized that this was much cleaner:

s.to_image((s.schedule.sort { |a,b| x = a.person_id <=> b.person_id; if x == 0 then a.start <=> b.start else x end }, 0, 2500, 1800, image) Sorted by person and then start date

Ruby is so cute!

Previous day | Next day

I'd love to hear about any questions, comments, suggestions or links that you might have. Your comments will not be posted on this website immediately, but will be e-mailed to me first. You can use this form to get in touch with me, or e-mail me at [email protected] .

Page: ruby
Updated: 2005-06-09
NOTE: ANTI-SPAM MEASURE NOW IN PLACE. Please answer the following question with the right number in order to send me your comment.
What is two minus one? (hint: one ;) )