Class: CommitStatisticsForCommitterInRepository
- Inherits:
-
Object
- Object
- CommitStatisticsForCommitterInRepository
- Defined in:
- lib/codespicuous/commitstatistics.rb
Instance Attribute Summary collapse
-
#commits ⇒ Object
writeonly
Sets the attribute commits.
Instance Method Summary collapse
- #amount_of_commits ⇒ Object
- #amount_of_commits_in_week(week_start) ⇒ Object
- #amount_of_weeks_committed ⇒ Object
- #commit(date, amount) ⇒ Object
- #first_week_committed ⇒ Object
-
#initialize ⇒ CommitStatisticsForCommitterInRepository
constructor
A new instance of CommitStatisticsForCommitterInRepository.
- #last_week_committed ⇒ Object
Constructor Details
#initialize ⇒ CommitStatisticsForCommitterInRepository
Returns a new instance of CommitStatisticsForCommitterInRepository.
7 8 9 |
# File 'lib/codespicuous/commitstatistics.rb', line 7 def initialize self.commits = {} end |
Instance Attribute Details
#commits=(value) ⇒ Object (writeonly)
Sets the attribute commits
5 6 7 |
# File 'lib/codespicuous/commitstatistics.rb', line 5 def commits=(value) @commits = value end |
Instance Method Details
#amount_of_commits ⇒ Object
16 17 18 |
# File 'lib/codespicuous/commitstatistics.rb', line 16 def amount_of_commits @commits.values.inject(0) { |sum, commits_of_week| sum += commits_of_week } end |
#amount_of_commits_in_week(week_start) ⇒ Object
24 25 26 |
# File 'lib/codespicuous/commitstatistics.rb', line 24 def amount_of_commits_in_week week_start @commits[week_start] ? @commits[week_start] : 0 end |
#amount_of_weeks_committed ⇒ Object
20 21 22 |
# File 'lib/codespicuous/commitstatistics.rb', line 20 def amount_of_weeks_committed @commits.size end |
#commit(date, amount) ⇒ Object
11 12 13 14 |
# File 'lib/codespicuous/commitstatistics.rb', line 11 def commit(date, amount) @commits[DateTime.parse(date.to_s)] ||= 0 @commits[DateTime.parse(date.to_s)] += amount.to_i end |
#first_week_committed ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/codespicuous/commitstatistics.rb', line 28 def first_week_committed commit_week = DateTime.now @commits.each_key { |date| commit_week = date if date < commit_week } commit_week end |
#last_week_committed ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/codespicuous/commitstatistics.rb', line 36 def last_week_committed commit_week = DateTime.new(1977) @commits.each_key { |date| commit_week = date if date > commit_week } commit_week end |