Skip to content

Instantly share code, notes, and snippets.

@Pcushing
Created June 15, 2012 00:54
Show Gist options
  • Save Pcushing/2933968 to your computer and use it in GitHub Desktop.
Save Pcushing/2933968 to your computer and use it in GitHub Desktop.
Andrew and Patrick crushing it on books
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