From: Gavin Sinclair Date: 2004-05-12T08:57:05+09:00 Subject: Re: Proposal: Object#send(nil) -> self On Wednesday, May 12, 2004, 2:38:53 AM, Robert wrote: > # how about > date_str = date.to_s.send(date_colour_msg) if date_colour_msg Of course there are plenty of alternatives, but that one (and the one below) seem more verbose than necessary. > OTOH you can do > date_str = case Date.today - date > when 0 then date.to_s.red > [...] > The more OO way would be to use a Hash: > COLORS = { > 0 => :red > ... > } > COLORS.default = default_color > date_str = COLORS[Date.today - date] I'm not so sure about that. That's an data-based approach; no active objects in sight. You can't use a range for a key in that particular hash either. >> That example's not too contrived, is it? > I found a bit irritating that you send :red, :yellow etc. to a String. That's the way ANSI highlighting works in whatever RAA package I was using two years ago when that example was current. I had a minor "need" for this behaviour yesterday, but the example above is perhaps more easily understood. Cheers, Gavin