Class: WordCounter

Inherits:
Object
  • Object
show all
Defined in:
lib/genderstat/word_counter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#countObject (readonly)

Returns the value of attribute count.



4
5
6
# File 'lib/genderstat/word_counter.rb', line 4

def count
  @count
end

#nameObject (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

Returns:

  • (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