Un–Rubify

Often times while writing meta programming code, I am using the eval function and doing manipulation on method/class/variable names.

Today I needed to un–Rubify a name. I haven’t seen this done regularly, and unfortunately there is no fun Rails method to do it (there is one for Rubifying a string).

So, here is my attempt at it, for anyone trying to solve the same problem:

1def unrubify(sentence)  
2  sentence.capitalize!
3  sentence.gsub!(/_(.)/) { $1.upcase }
4  return sentence 
5end

If you have any suggestions, please let me know!

Paul Pagel, Chief Executive Officer

Paul Pagel co-founded 8th Light in 2006, and has been a driving force in the software community ever since.

Interested in 8th Light's services? Let's talk.

Contact Us