module SublabCalendar class Occurrence < SimpleDelegator attr_reader :event def initialize(occurrence, event) @event = event super(occurrence) end def to_h { summary: summary, start: start_time, end: end_time } end def to_json(*args) to_h.to_json(*args) end def to_s "<#{self.class} #{self.to_h}>" end alias_method :inspect, :to_s def <=>(other) self.dtstart.to_datetime <=> other.dtstart.to_datetime end def ==(o) o.class == self.class && o.state == state end alias_method :eql?, :== def summary event.summary end def description event.description end def dtstart start_time.to_datetime end protected def state [event.uid, start_time, end_time] end end end