Class: Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_contributor_genders/analyzer.rb

Instance Method Summary collapse

Constructor Details

#initialize(names) ⇒ Analyzer

Returns a new instance of Analyzer.



4
5
6
# File 'lib/rails_contributor_genders/analyzer.rb', line 4

def initialize(names)
  @names = names
end

Instance Method Details

#resultsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rails_contributor_genders/analyzer.rb', line 8

def results
  results_hash = {
    male: 0,
    female: 0,
    mostly_male: 0,
    mostly_female: 0,
    andy: 0
  }

  detector = GenderDetector.new

  first_names.each do |name|
    gender = detector.get_gender(name)
    results_hash[gender] += 1
  end

  results_hash
end