Created
February 19, 2014 17:24
-
-
Save xander-miller/9096851 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class String | |
def title_case | |
articles = ['a','the','of'] | |
words_array = self.downcase.split(" ") | |
words_array.each do |word| | |
unless articles.include?(word) | |
word.capitalize! | |
end | |
end | |
words_array.first.capitalize! | |
words_array.join(" ") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment