Slotter

Create and manipulate time slots simply and easily. The gem allows you to perform operations like addition, subtraction and splitting on time slots. Time slots are immutable.

Installation

sudo gem install slotter --source http://gemcutter.org

Examples

a = TimeSlot.new(Chronic.parse("today 10:00"), Chronic.parse("today 11:00"))
b = TimeSlot.new(Chronic.parse("today 10:00"), Chronic.parse("today 12:00"))
c = TimeSlot.new(Chronic.parse("today 11:00"), Chronic.parse("today 12:00"))

Concatenating

a + b #=> [#<TimeSlot:0x1018f90b0 @finish=Sun Nov 01 12:00:00 +0000 2009, 
          @start=Sun Nov 01 10:00:00 +0000 2009>]
a + c #=> [#<TimeSlot:0x1018df890 @finish=Sun Nov 01 12:00:00 +0000 2009, 
          @start=Sun Nov 01 10:00:00 +0000 2009>]

Subtracting

b - a #=> [#<TimeSlot:0x1018d91c0 @finish=Sun Nov 01 12:00:00 +0000 2009, 
          @start=Sun Nov 01 11:00:00 +0000 2009>]
b - c #=> [#<TimeSlot:0x1018dc528 @finish=Sun Nov 01 11:00:00 +0000 2009, 
          @start=Sun Nov 01 10:00:00 +0000 2009>]

Splitting

b.split(3600) #=> 
          [#<TimeSlot:0x1018d57f0 @finish=Sun Nov 01 11:00:00 +0000 2009, 
          @start=Sun Nov 01 10:00:00 +0000 2009>, 
          #<TimeSlot:0x1018d5728 @finish=Sun Nov 01 12:00:00 +0000 2009,        
          @start=Sun Nov 01 11:00:00 +0000 2009>]

Copyright © 2009 Bjarki Gudlaugsson. See LICENSE for details.