Skip to content

Instantly share code, notes, and snippets.

@Solnse
Created December 14, 2012 07:40
Show Gist options
  • Save Solnse/4283461 to your computer and use it in GitHub Desktop.
Save Solnse/4283461 to your computer and use it in GitHub Desktop.
titleize verbose code
def titleize(word)
title = ""
words = word.split
words.each do |w|
if words.first == w
w.capitalize!
title << w
title << " " unless w == words.last
else
w.capitalize! unless ["a", "and", "the", "over"].include?(w.downcase)
title << w
title << " " unless w == words.last
end
end
title
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment