Created
May 21, 2013 00:09
-
-
Save abrongersma/5616633 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 Book | |
| attr_accessor :title | |
| def initialize | |
| @title = {} | |
| end | |
| def title | |
| words = @title.split | |
| lower = %w{the a in of an and} # don't caps me bro! | |
| words.each do |t| | |
| if !lower.include? t | |
| t.capitalize! | |
| else | |
| words[0].capitalize! #in case title starts with A or The. | |
| end | |
| end | |
| words.join " " | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment