END; require_once "include/calendar.php"; require_once "include/planner-include.php"; require_once "include/header.inc.php"; ?>

Tasks

BCCheck out http://rubyforge.org/projects/ri-emacs/ : Chat with :kuribas on sterling.freenode.net#ruby-lang (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)

Notes

1. Adventures with Ruby

Categories: 2005.02.04:4 -- Permalink, Comment form

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!

Permalink, Comment form -- Back to top