Class: Git::Heatmap::Aggregate
- Inherits:
-
Object
- Object
- Git::Heatmap::Aggregate
- Defined in:
- lib/git/heatmap/commits.rb
Instance Attribute Summary collapse
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#earliest_commit_at ⇒ Object
readonly
Returns the value of attribute earliest_commit_at.
-
#latest_commit_at ⇒ Object
readonly
Returns the value of attribute latest_commit_at.
-
#maximum ⇒ Object
readonly
Returns the value of attribute maximum.
-
#periods ⇒ Object
readonly
Returns the value of attribute periods.
Instance Method Summary collapse
- #<<(commit) ⇒ Object
-
#initialize(filter) ⇒ Aggregate
constructor
A new instance of Aggregate.
- #size ⇒ Object
Constructor Details
#initialize(filter) ⇒ Aggregate
Returns a new instance of Aggregate.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/git/heatmap/commits.rb', line 26 def initialize(filter) @filter = filter @commits = {} @periods = {} @earliest_commit_at = nil @latest_commit_at = nil @maximum = 0 end |
Instance Attribute Details
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
38 39 40 |
# File 'lib/git/heatmap/commits.rb', line 38 def commits @commits end |
#earliest_commit_at ⇒ Object (readonly)
Returns the value of attribute earliest_commit_at.
41 42 43 |
# File 'lib/git/heatmap/commits.rb', line 41 def earliest_commit_at @earliest_commit_at end |
#latest_commit_at ⇒ Object (readonly)
Returns the value of attribute latest_commit_at.
42 43 44 |
# File 'lib/git/heatmap/commits.rb', line 42 def latest_commit_at @latest_commit_at end |
#maximum ⇒ Object (readonly)
Returns the value of attribute maximum.
48 49 50 |
# File 'lib/git/heatmap/commits.rb', line 48 def maximum @maximum end |
#periods ⇒ Object (readonly)
Returns the value of attribute periods.
39 40 41 |
# File 'lib/git/heatmap/commits.rb', line 39 def periods @periods end |
Instance Method Details
#<<(commit) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/git/heatmap/commits.rb', line 50 def << commit return if @commits.include?(commit.oid) @commits[commit.oid] = commit = commit. time = [:time] key = @filter.key(time) commits = (@periods[key] ||= []) commits << commit if commits.size > @maximum @maximum = commits.size end if @earliest_commit_at.nil? or time < @earliest_commit_at @earliest_commit_at = time end if @latest_commit_at.nil? or time > @latest_commit_at @latest_commit_at = time end end |
#size ⇒ Object
44 45 46 |
# File 'lib/git/heatmap/commits.rb', line 44 def size @commits.size end |