Class: String
Instance Method Summary collapse
-
#humanize ⇒ Object
Returns the string with the very first character capitalized, and with underscores substituted by spaces.
-
#titleize ⇒ Object
Returns the string with the first character of each word capitalized, and with underscores substituted by spaces.
Instance Method Details
#humanize ⇒ Object
Returns the string with the very first character capitalized, and with underscores substituted by spaces.
9 10 11 |
# File 'lib/commands/lib/string_inflectors.rb', line 9 def humanize self.gsub(/_/, " ").capitalize end |
#titleize ⇒ Object
Returns the string with the first character of each word capitalized, and with underscores substituted by spaces.
4 5 6 |
# File 'lib/commands/lib/string_inflectors.rb', line 4 def titleize self.humanize.gsub(/\b('?[a-z])/) { $1.capitalize } end |