class TimeClock::Shift

Attributes

end_time[R]
start_time[R]

Public Class Methods

new(start_time, end_time) click to toggle source
# File lib/time_clock/shift.rb, line 8
def initialize(start_time, end_time)
  raise EndTimeAfterStartTimeError unless end_time > start_time
  @start_time, @end_time = start_time.to_time, end_time.to_time
end

Public Instance Methods

==(value) click to toggle source
# File lib/time_clock/shift.rb, line 21
def ==(value)
  start_time == value.start_time && end_time == value.end_time
end
overlapping_seconds(shift) click to toggle source
# File lib/time_clock/shift.rb, line 17
def overlapping_seconds(shift)
  [[end_time,shift.end_time].min - [start_time,shift.start_time].max,0].max
end
overlaps?(shift) click to toggle source
# File lib/time_clock/shift.rb, line 13
def overlaps?(shift)
  start_time <= shift.end_time && end_time >= shift.start_time
end