Skip to content

Instantly share code, notes, and snippets.

@photomattmills
Last active December 21, 2015 09:49
Show Gist options
  • Save photomattmills/6288060 to your computer and use it in GitHub Desktop.
Save photomattmills/6288060 to your computer and use it in GitHub Desktop.
class Phrase
def initialize(words)
@words = words
end
def word_count
@words.downcase.scan(/\w+/).inject(Hash.new(0)) { |list,word| list.merge!({ word => list[word]+1 }) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment