#coding   #ruby

coding art

November 18, 2006

this code is a piece of art. It was the most inspiring use of ruby i've seen in a while. First there is:

class << TODOS = IO.read('TODO')
  # hand made TODO api here

which wraps the String just loaded from disk in its very own, perfectly suited API. This is like hand made english cut vs. H&M. And than there is:

items.grep(regexp).instance_eval do
   def display
     # custom display function here

which again, does nicely fit a custom API around the found data. Doing it on the fly, no base classes, interfaces or and other sign of bothering the user with extraneous code. I just love it.

share this: