Posted By


xurde on 12/28/07

Tagged


Statistics


Viewed 140 times
Favorited by 1 user(s)

String.capitalize_each_word


/ Published in: Ruby
Save to your folder(s)

Extends the String class to make a method that lets you easily capitalize the each word in a given string.


Copy this code and paste it in your HTML
  1. class String
  2. def capitalize_each_word
  3. (self.split(' ').each {|w| w.capitalize! }).join(' ')
  4. end
  5. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.