Class: IcalImporter::SingleEventBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ical_importer/single_event_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ SingleEventBuilder

Returns a new instance of SingleEventBuilder.



5
6
7
8
# File 'lib/ical_importer/single_event_builder.rb', line 5

def initialize(event)
  @event = RemoteEvent.new event
  @local_event = LocalEvent.new @event.event_attributes
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



3
4
5
# File 'lib/ical_importer/single_event_builder.rb', line 3

def event
  @event
end

#local_eventObject (readonly)

Returns the value of attribute local_event.



3
4
5
# File 'lib/ical_importer/single_event_builder.rb', line 3

def local_event
  @local_event
end

Instance Method Details

#buildObject

Get single-occurrence events built and get a lits of recurrence events, these must be build last



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ical_importer/single_event_builder.rb', line 12

def build
  # handle recuring events
  @local_event.tap do |le|
    if @event.rrule.present?
      @rrule = @event.rrule.first # only support recurrence on one schedule
      # set out new event's basic rucurring properties
      le.attributes = recurrence_attributes

      set_date_exclusion
      frequency_set
    else # make sure we remove this if it changed
      le.attributes = non_recurrence_attributes
    end
  end
end