Skip to content

Instantly share code, notes, and snippets.

@abrongersma
Created May 21, 2013 00:09
Show Gist options
  • Select an option

  • Save abrongersma/5616633 to your computer and use it in GitHub Desktop.

Select an option

Save abrongersma/5616633 to your computer and use it in GitHub Desktop.
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