Class: String

Inherits:
Object show all
Defined in:
lib/commands/lib/string_inflectors.rb

Instance Method Summary collapse

Instance Method Details

#humanizeObject

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

#titleizeObject

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