Class: LastWeeksCommitStats
- Inherits:
-
Object
- Object
- LastWeeksCommitStats
- Includes:
- StatsHash
- Defined in:
- lib/gitstats/stats/commit/time.rb
Instance Method Summary collapse
-
#initialize ⇒ LastWeeksCommitStats
constructor
A new instance of LastWeeksCommitStats.
- #update(commit) ⇒ Object
Methods included from StatsHash
Constructor Details
#initialize ⇒ LastWeeksCommitStats
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 |