Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Book
- attr_reader :title
- def title=(new_book)
- words = new_book.to_s.split(' ')
- words.map! { |x|
- if x == words[0]
- x.capitalize!
- elsif x == "the" || x == "and" || x == "a" || x == "an" || x == "of" || x == "in"
- x = x.downcase
- else
- x.capitalize!
- x
- end
- }
- @title = words.join(' ')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment