Sha256: 89327af1c633af2e24cc5216ecfcca88b0240cd9b2b70426df9708d34a9ee552

Contents?: true

Size: 482 Bytes

Versions: 2

Compression:

Stored size: 482 Bytes

Contents

module TimeClock
  class Comparison

    attr_reader :start_time, :end_time, :calendar

    def initialize(start_time, end_time, calendar=TimeClock.default_calendar)
      @start_time, @end_time, @calendar = start_time, end_time, calendar
    end

    def period
      @period ||= Shift.new(start_time, end_time)
    end

    def seconds
      calendar.shifts.inject(0) do |total_seconds, shift|
        total_seconds + period.overlapping_seconds(shift)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
time_clock-0.0.2 lib/time_clock/comparison.rb
time_clock-0.0.1 lib/time_clock/comparison.rb