Class: Livecal::CalendarSource

Inherits:
Object
  • Object
show all
Defined in:
lib/livecal/calendar_source.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ CalendarSource

Returns a new instance of CalendarSource.



21
22
23
# File 'lib/livecal/calendar_source.rb', line 21

def initialize(source)
  @source = source
end

Class Method Details

.from_file(path) ⇒ Object



13
14
15
# File 'lib/livecal/calendar_source.rb', line 13

def self.from_file(path)
  from_string(File.read(path))
end

.from_string(contents) ⇒ Object



17
18
19
# File 'lib/livecal/calendar_source.rb', line 17

def self.from_string(contents)
  Icalendar::Calendar.parse(contents).collect { |source| new(source) }
end

.from_url(url) ⇒ Object



9
10
11
# File 'lib/livecal/calendar_source.rb', line 9

def self.from_url(url)
  from_string(Net::HTTP.get(URI(url)))
end

Instance Method Details

#recurring_changesObject



25
26
27
# File 'lib/livecal/calendar_source.rb', line 25

def recurring_changes
  events.select { |event| event.rrule.empty? && event.recurrence_id }
end

#recurring_eventsObject



29
30
31
# File 'lib/livecal/calendar_source.rb', line 29

def recurring_events
  events.select { |event| event.rrule.any? }
end

#standalone_eventsObject



33
34
35
# File 'lib/livecal/calendar_source.rb', line 33

def standalone_events
  events.select { |event| event.rrule.empty? && event.recurrence_id.nil? }
end