Created
June 15, 2012 00:54
-
-
Save Pcushing/2933968 to your computer and use it in GitHub Desktop.
Andrew and Patrick crushing it on books
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 Book | |
attr_accessor :title | |
def initialize | |
@title = "" | |
end | |
def title=(name) | |
arr = name.split | |
no_caps = ["the", "an", "a", "and", "in"] | |
arr.each do |word| | |
if (no_caps.include?word) && (word != arr[0]) | |
word | |
else | |
word.capitalize! | |
end | |
end | |
@title = arr.join(" ") | |
@title | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment