I\'m trying to write a method that will capitalize titles. It should capitalize not every word, but only the big words if you will. Sometimes, it has to capitalize every wor
Building off of Josh Voigts comment:
def titleize(name)
lowercase_words = %w{a an the and but or for nor of}
name.split.each_with_index.map{|x, index| lowercase_words.include?(x) && index > 0 ? x : x.capitalize }.join(" ")
end
You might want make lowercase_words a constant and move it out of the function since they won't ever change.