Sha256: 67998079aca5ff80021048cc9b6912634ce5cca35ba2ebc534d84c97e455fca6
Contents?: true
Size: 1022 Bytes
Versions: 2
Compression:
Stored size: 1022 Bytes
Contents
module Reservation module Schedule # # a utility class to match the start and end times of an Event instance, without considering the event date # class Interval attr_accessor :start, :finish def initialize start, finish @start, @finish = start, finish end # true if the start time and finish time of the given event matches start and finish times of this Interval def matches? event start.matches_time?(event.start) && finish.matches_time?(event.finish) end # build a new Event with this Interval's start and finish times, on the given date def generate date Event.new :start => start.change(date), :finish => finish.change(date) end def self.from start, finish new HourMinute.parse(start), HourMinute.parse(finish) end def self.parse intervals intervals.split(',').map { |i| self.from(*i.split('-')) } end def to_s "#{start}-#{finish}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reservation-0.1.0 | lib/reservation/interval.rb |
reservation-0.0.6 | lib/reservation/interval.rb |