Class: CommitTime
- Inherits:
-
Object
- Object
- CommitTime
- Defined in:
- lib/commit-time.rb
Instance Attribute Summary collapse
-
#average_time ⇒ Object
readonly
Returns the value of attribute average_time.
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#datetimes ⇒ Object
readonly
Returns the value of attribute datetimes.
-
#times ⇒ Object
readonly
Array of times for between each commit, in minutes.
-
#total_time ⇒ Object
readonly
Returns the value of attribute total_time.
Instance Method Summary collapse
-
#initialize(datetimes) ⇒ CommitTime
constructor
A new instance of CommitTime.
- #marshal_dump ⇒ Object
- #marshal_load(array) ⇒ Object
Constructor Details
#initialize(datetimes) ⇒ CommitTime
Returns a new instance of CommitTime.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/commit-time.rb', line 11 def initialize(datetimes) @datetimes = datetimes @times = datetimes.each_cons(2).map { |a, b| ((a - b).abs * 24 * 60).round.to_i } @commits = datetimes.count real_times = @times.find_all { |time| time < 60 } @average_time = if real_times.empty? 0 else real_times.reduce(:+).to_f / real_times.count end @total_time = @average_time * @commits end |
Instance Attribute Details
#average_time ⇒ Object (readonly)
Returns the value of attribute average_time.
8 9 10 |
# File 'lib/commit-time.rb', line 8 def average_time @average_time end |
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
7 8 9 |
# File 'lib/commit-time.rb', line 7 def commits @commits end |
#datetimes ⇒ Object (readonly)
Returns the value of attribute datetimes.
4 5 6 |
# File 'lib/commit-time.rb', line 4 def datetimes @datetimes end |
#times ⇒ Object (readonly)
Array of times for between each commit, in minutes
6 7 8 |
# File 'lib/commit-time.rb', line 6 def times @times end |
#total_time ⇒ Object (readonly)
Returns the value of attribute total_time.
9 10 11 |
# File 'lib/commit-time.rb', line 9 def total_time @total_time end |
Instance Method Details
#marshal_dump ⇒ Object
26 27 28 |
# File 'lib/commit-time.rb', line 26 def marshal_dump [@datetimes, @times, @commits, @average_time, @total_time] end |
#marshal_load(array) ⇒ Object
30 31 32 |
# File 'lib/commit-time.rb', line 30 def marshal_load array @datetimes, @times, @commits, @average_time, @total_time = array end |