From 7047e5562118d23c66c390b004f74ed35b90ab14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Glauco=20Cust=C3=B3dio?= Date: Thu, 25 Feb 2016 23:05:54 -0300 Subject: Add upcase_first method --- activesupport/lib/active_support/inflector/methods.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activesupport/lib/active_support/inflector') diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index f741c0bfb8..3fbc19ddf8 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -140,6 +140,13 @@ module ActiveSupport result end + # Converts just the first character to uppercase. + # + # 'what a Lovely Day'.upcase_first # => "What a Lovely Day" + def upcase_first(string) + string[0].upcase.concat(string[1..-1]) + end + # Capitalizes all the words and replaces some characters in the string to # create a nicer looking title. +titleize+ is meant for creating pretty # output. It is not used in the Rails internals. -- cgit v1.2.3