Skip to content

Instantly share code, notes, and snippets.

@tamouse
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamouse/9e073705f34915c7ce3a to your computer and use it in GitHub Desktop.
Save tamouse/9e073705f34915c7ce3a to your computer and use it in GitHub Desktop.
STOPWORDS=%w[a an and in of the].freeze
def proper_title(t)
t.to_s.split.inject([]) do |m, x|
if m.empty? || ! STOPWORDS.include?(x)
m << x.capitalize
else
m << x
end
end.join(" ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment