Capitalize each word in a string

How do you capitalize each word in a string? Essentially, Ruby’s
version of PHP’s ucwords()? Thanks.

How do you capitalize each word in a string? Essentially, Ruby’s
version of PHP’s ucwords()? Thanks.

“this is a test sentence.”.titleize

→ “This Is A Test Sentence.”

http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/String/Inflections.html#M000281

steve.