lib/toggl/worktime/merger.rb in toggl-worktime-0.1.5 vs lib/toggl/worktime/merger.rb in toggl-worktime-0.1.6
- old
+ new
@@ -2,16 +2,19 @@
module Toggl
module Worktime
# Time-entries merger
class Merger
+ attr_reader :total_time
+
def initialize(time_entries)
@time_entries = time_entries
@current_start = nil
@current_stop = nil
@continuing = true
@last_stop = nil
+ @total_time = 0
end
def merge
work_time = []
time_entries_each do |start, stop|
@@ -33,9 +36,10 @@
start = parse_date(te['start'], zone_offset)
stop = parse_date(te['stop'], zone_offset)
@last_stop = stop
@current_start = start if @current_start.nil?
@current_stop = stop if @current_stop.nil?
+ @total_time += stop - start
yield [start, stop]
end
end
def parse_date(date, zone_offset)