class String # Converts strings to UpperCamelCase. #-- # Graciously borrowed from Rails & ActiveSupport # http://svn.rubyonrails.org/rails/tags/rel_2-0-2/activesupport/lib/active_support/inflector.rb def camelize self.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } end # The reverse of +camelize+. Makes an underscored form from the expression in the string. #-- # Graciously borrowed from Rails & ActiveSupport # http://svn.rubyonrails.org/rails/tags/rel_2-0-2/activesupport/lib/active_support/inflector.rb def underscore self.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end end