Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class KeywordCount
- attr_reader :keywords, :text
- def initialize(keywords, text)
- @keywords = keywords
- @text = text
- end
- def counts
- @counts ||= keywords.inject({}) do |h, kw|
- h[kw] = text.scan(kw).lenth; h
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement