Class: WordCounter
- Inherits:
-
Object
- Object
- WordCounter
- Defined in:
- lib/genderstat/word_counter.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(filename) ⇒ WordCounter
constructor
A new instance of WordCounter.
- #is_in_here?(word_in_question) ⇒ Boolean
Constructor Details
#initialize(filename) ⇒ WordCounter
Returns a new instance of WordCounter.
6 7 8 9 10 |
# File 'lib/genderstat/word_counter.rb', line 6 def initialize filename @words = Set.new YAML.load_file(filename) @name = filename.split('_').first.split('/').last @count = 0 end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
4 5 6 |
# File 'lib/genderstat/word_counter.rb', line 4 def count @count end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/genderstat/word_counter.rb', line 4 def name @name end |
Instance Method Details
#is_in_here?(word_in_question) ⇒ Boolean
12 13 14 |
# File 'lib/genderstat/word_counter.rb', line 12 def is_in_here? word_in_question @count += 1 if @words.include? word_in_question end |