lib/active_support/inflector/methods.rb in activesupport-5.0.0.beta3 vs lib/active_support/inflector/methods.rb in activesupport-5.0.0.beta4
- old
+ new
@@ -138,9 +138,18 @@
end
result
end
+ # Converts just the first character to uppercase.
+ #
+ # upcase_first('what a Lovely Day') # => "What a Lovely Day"
+ # upcase_first('w') # => "W"
+ # upcase_first('') # => ""
+ def upcase_first(string)
+ string.length > 0 ? 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.
#
# +titleize+ is also aliased as +titlecase+.