Permalink
Browse files

Merge pull request #23895 from glaucocustodio/add_upcase_first_method

Add upcase_first method
  • Loading branch information...
rafaelfranca committed Mar 30, 2016
2 parents 0df82a6 + 7047e55 commit 3be1a75f3fff1042934ba60ae4093237a6b31712
@@ -1,3 +1,7 @@
* Add `String#upcase_first` method.
*Glauco Custódio*
* Prevent `Marshal.load` from looping infinitely when trying to autoload a constant
which resolves to a different name.
@@ -222,6 +222,13 @@ def humanize(options = {})
ActiveSupport::Inflector.humanize(self, options)
end
# Converts just the first character to uppercase.
#
# 'what a Lovely Day'.upcase_first # => "What a Lovely Day"
def upcase_first
ActiveSupport::Inflector.upcase_first(self)
end
# Creates a foreign key name from a class name.
# +separate_class_name_and_id_with_underscore+ sets whether
# the method should put '_' between the name and 'id'.
@@ -140,6 +140,13 @@ def humanize(lower_case_and_underscored_word, options = {})
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.
@@ -76,6 +76,10 @@ def test_titleize
end
end
def test_upcase_first
assert_equal "What a Lovely Day", "what a Lovely Day".upcase_first
end
def test_camelize
CamelToUnderscore.each do |camel, underscore|
assert_equal(camel, underscore.camelize)

0 comments on commit 3be1a75

Please sign in to comment.