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"


90
91
92
93
94
95
96
# File 'lib/titleize.rb', line 90

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

#titleize!Object Also known as: titlecase!



99
100
101
# File 'lib/titleize.rb', line 99

def titleize!
  replace(titleize)
end