Created
June 16, 2012 01:05
-
-
Save pzaich/2939444 to your computer and use it in GitHub Desktop.
Book Class
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 | |
| def initialize | |
| end | |
| def title | |
| @book_title | |
| end | |
| def title=(book_title) | |
| lowercase_words = ["in","a","and", "the", "an" ] | |
| book_title = book_title.split(' ') | |
| book_title.collect! do |word| | |
| if lowercase_words.include?(word) | |
| word | |
| else | |
| word.capitalize | |
| end | |
| end | |
| book_title[0].capitalize! | |
| @book_title = book_title.join(' ') | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment