Method: String#capitalize_first

Defined in:
lib/jinx/helpers/inflector.rb

#capitalize_firstString

Returns this String with the first letter capitalized and other letters preserved.

Examples:

"rosesAreRed".capitalize_first #=> "RosesAreRed"

Returns:

  • (String)

    this String with the first letter capitalized and other letters preserved



17
18
19
# File 'lib/jinx/helpers/inflector.rb', line 17

def capitalize_first
  sub(/(?:^)(.)/) { $1.upcase }
end