class Reservation::Schedule::Interval

a utility class to match the start and end times of an Event instance, without considering the event date

Attributes

finish[RW]
start[RW]

Public Class Methods

from(start, finish) click to toggle source
# File lib/reservation/interval.rb, line 23
def self.from start, finish
  new HourMinute.parse(start), HourMinute.parse(finish)
end
new(start, finish) click to toggle source
# File lib/reservation/interval.rb, line 9
def initialize start, finish
  @start, @finish = start, finish
end
parse(intervals) click to toggle source
# File lib/reservation/interval.rb, line 27
def self.parse intervals
  intervals.split(',').map { |i| self.from(*i.split('-')) }
end

Public Instance Methods

generate(date) click to toggle source

build a new Event with this Interval’s start and finish times, on the given date

# File lib/reservation/interval.rb, line 19
def generate date
  Event.new :start => start.change(date), :finish => finish.change(date)
end
matches?(event) click to toggle source

true if the start time and finish time of the given event matches start and finish times of this Interval

# File lib/reservation/interval.rb, line 14
def matches? event
  start.matches_time?(event.start) && finish.matches_time?(event.finish)
end
to_s() click to toggle source
# File lib/reservation/interval.rb, line 31
def to_s
  "#{start}-#{finish}"
end