Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/titleize.rb

Instance Method Summary collapse

Instance Method Details

#titleize(opts = {}) ⇒ Object Also known as: titlecase

Capitalizes most words to create a nicer looking title string.

The list of “small words” which are not capped comes from the New York Times Manual of Style, plus 'vs' and 'v'.

titleize is also aliased as titlecase.

"notes on a scandal" # => "Notes on a Scandal"
"the good german"    # => "The Good German"

84
85
86
87
88
89
90
# File 'lib/titleize.rb', line 84

def titleize(opts={})
  if defined? ActiveSupport::Inflector
    ActiveSupport::Inflector.titleize(self, opts)
  else
    Titleize.titleize(self)
  end
end

#titleize!Object Also known as: titlecase!


93
94
95
# File 'lib/titleize.rb', line 93

def titleize!
  replace(titleize)
end