diff options
Diffstat (limited to 'activesupport/lib/active_support/inflector.rb')
-rw-r--r-- | activesupport/lib/active_support/inflector.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index 281ea3f4b9..7009628cb3 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -112,6 +112,10 @@ module Inflector def camelize(lower_case_and_underscored_word) lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } end + + def titleize(word) + humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize } + end def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase @@ -157,4 +161,4 @@ module Inflector end end -require File.dirname(__FILE__) + '/inflections'
\ No newline at end of file +require File.dirname(__FILE__) + '/inflections' |