Rubyize this : 3rd edition

It’s time for another phenomenal edition of the fantastic Rubyize this serie (how humble is that?)

But before we go any further, I’d like to briefly talk about a brand new web 2.0 rails app that has been developed by Marc-AndrĂ© Cournoyer, a Ruby/Rails guru from Montreal. The app is called RefactorMyCode and became instantly popular among the coding community. The principle behind : People submit chunks of their own code that they would wish to see improved. Every members can then try their luck and submit their refactored version of the code. Marc told me that the Rubyize this serie partly inspired him in the creation of this application… it’s always cool to hear things like that!

Ok, now here is what we have to rubyize today :

Yikes! Pretty ugly this week… that’s how I like them.

Wordpress doesn’t want that you write code… I suggest that you use RefactorMyCode to post your solution instead. You can also use pastie and just write a comment here with the URL to your snippet. The trackbacks are working correctly now so I strongly suggest that you use RefactorMyCode.

If for some reasons you do not wish to use RmC or Pastie, here are some precautions you should take :

  1. Code indentation with spaces doesn’t work. Use another character… an underscore maybe?
  2. Do not use <% or %> (it shouldn’t be a problem this week)
  3. COPY your code in your clipboard before sending it for safety measure… that way if wordpress screw up your code, you will be able to post it again rapidly by just removing what WordPress doesn’t like

Have fun!