Class: LastWeeksCommitStats

Inherits:
Object
  • Object
show all
Includes:
StatsHash
Defined in:
lib/gitstats/stats/commit/time.rb

Instance Method Summary collapse

Methods included from StatsHash

#each_sorted, #method_missing

Constructor Details

#initializeLastWeeksCommitStats

Returns a new instance of LastWeeksCommitStats.



92
93
94
95
# File 'lib/gitstats/stats/commit/time.rb', line 92

def initialize
  @hash = Hash.new
  @base = Time.now
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class StatsHash

Instance Method Details

#update(commit) ⇒ Object



97
98
99
100
101
102
103
104
105
# File 'lib/gitstats/stats/commit/time.rb', line 97

def update(commit)
  return if commit[:time] > @base

  diff = ((@base - commit[:time]) / 604800).to_i
  return if diff >= 52

  @hash[diff] ||= CommitStats.new
  @hash[diff].update(commit)
end