Class: Wc::Reader
- Inherits:
-
Object
- Object
- Wc::Reader
- Defined in:
- lib/wc/reader.rb
Constant Summary collapse
- HIDE_LIST =
['or', 'the', 'of', 'a', 'if', 'to', 'and', 'in', 'is', 'are']
Class Method Summary collapse
Class Method Details
.consume(a_text) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wc/reader.rb', line 16 def self.consume(a_text) occurrences = Hash.new { |h, k| h[k] = 0 } words = a_text.split words.each { |w| if ! HIDE_LIST.include?(w.downcase) occurrences[w.downcase] += 1 end } occurrences end |