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
96
97
# File 'lib/gitstats/stats/commit/time.rb', line 92

def initialize
  today = Time.now.to_date
  nextCwStart = Date.commercial(today.cwyear,today.cweek)+7
  @hash = Hash.new
  @base = nextCwStart.to_time
end

Dynamic Method Handling

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

Instance Method Details

#update(commit) ⇒ Object



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

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