Sha256: 606e600a04e093cb62cdd6a83c60d4addf7a2f493c60174c67200d88c0f15169
Contents?: true
Size: 628 Bytes
Versions: 2
Compression:
Stored size: 628 Bytes
Contents
module TimeClock class Shift class EndTimeAfterStartTimeError < ArgumentError; end attr_reader :start_time, :end_time def initialize(start_time, end_time) raise EndTimeAfterStartTimeError unless end_time > start_time @start_time, @end_time = start_time, end_time end def overlaps?(shift) start_time <= shift.end_time && end_time >= shift.start_time end def overlapping_seconds(shift) [[end_time,shift.end_time].min - [start_time,shift.start_time].max,0].max end def ==(value) start_time == value.start_time && end_time == value.end_time end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
time_clock-0.0.2 | lib/time_clock/shift.rb |
time_clock-0.0.1 | lib/time_clock/shift.rb |