Use a parser. There is ruby_parse gem, just perfect for the occasion. I've once tried to create something similar: https://github.com/MatmaRex/crude - examples included. -- Matma Rex