Monday, November 12, 2007

Ruby One-Liners


#removes double quotes at beginning and end of string
some_string.gsub!(/\A"(.*)"\z/m, '\1')

#turns ActiveRecord::RecordNotFound into active_record_not_found
Klass.to_s.delete(':').gsub( /([A-Za-z])([A-Z])/, '\1' << '_' << '\2' ).downcase

0 hashings:

This blog began on Monday, September 27, 2004.
Hits since 2/20/2007:
free hit counters
free hit counters