Created
December 14, 2012 06:32
-
-
Save Solnse/4283166 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def titleize(word) | |
words = [] | |
result = "" | |
words = word.split | |
num = words.count | |
while num > 0 | |
words.each do |word| | |
word.capitalize! | |
result << word | |
result << " " unless num <= 1 | |
end | |
num -= 1 | |
end | |
return result | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment