Class: CalendarAssistant::LocationEventRepository

Inherits:
EventRepository show all
Defined in:
lib/calendar_assistant/location_event_repository.rb

Instance Attribute Summary

Attributes inherited from EventRepository

#calendar, #calendar_id, #config

Instance Method Summary collapse

Methods inherited from EventRepository

#delete, #in_tz, #initialize, #new, #update

Constructor Details

This class inherits a constructor from CalendarAssistant::EventRepository

Instance Method Details

#create(time, location, predicates: {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/calendar_assistant/location_event_repository.rb', line 8

def create(time, location, predicates: {})
  # find pre-existing events that overlap
  existing_event_set = find time, predicates: predicates

  # augment event end date appropriately
  range = CalendarAssistant.date_range_cast time

  event = super(
    transparency: CalendarAssistant::Event::Transparency::TRANSPARENT,
    start: range.first, end: range.last,
    summary: "#{Event.location_event_prefix(@config)}#{location}",
  )

  modify_location_events(event, existing_event_set)
end

#find(time, predicates: {}) ⇒ Object



3
4
5
6
# File 'lib/calendar_assistant/location_event_repository.rb', line 3

def find(time, predicates: {})
  event_set = super time, predicates: predicates
  event_set.new event_set.events.select { |e| e.location_event? }
end