Revision: 20445
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 16, 2009 11:26 by chrisaiv
Initial Code
# This helper is opening up core Ruby String class
# in order to add a new method to all Strings
class String
# Ruby has a capitalize method (used below) which capitalizes the
# first letter of a string. But in order to capitalize the first
# letter of EVERY word we have to write our own.
def titleize
self.split(' ').collect {|word| word.capitalize}.join(" ")
end
end
Initial URL
Initial Description
Don't forget to use require 'directory/name_of_class'
Initial Title
Ruby: Extend String Class to Capitalize Every Single Word
Initial Tags
ruby
Initial Language
Ruby