Class: Reponaut::StatisticsCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/reponaut/statistics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repos) ⇒ StatisticsCalculator

Returns a new instance of StatisticsCalculator.



5
6
7
# File 'lib/reponaut/statistics.rb', line 5

def initialize(repos)
  @repos = repos
end

Instance Attribute Details

#reposObject (readonly)

Returns the value of attribute repos.



3
4
5
# File 'lib/reponaut/statistics.rb', line 3

def repos
  @repos
end

Instance Method Details

#language_countsObject



9
10
11
12
13
# File 'lib/reponaut/statistics.rb', line 9

def language_counts
  langs = Hash.new { |hash, key| hash[key] = 0 }
  repos.group_by { |r| r.language }.map { |e| langs[e[0]] = e[1].count }
  langs
end