Class: Calagator::VCalendar
- Inherits:
-
Struct
- Object
- Struct
- Calagator::VCalendar
- Defined in:
- lib/calagator/vcalendar.rb
Constant Summary collapse
- VENUE_CONTENT_RE =
/^BEGIN:VVENUE$.*?^END:VVENUE$/m.freeze
Instance Attribute Summary collapse
-
#ri_cal_calendar ⇒ Object
Returns the value of attribute ri_cal_calendar.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#ri_cal_calendar ⇒ Object
Returns the value of attribute ri_cal_calendar
4 5 6 |
# File 'lib/calagator/vcalendar.rb', line 4 def ri_cal_calendar @ri_cal_calendar end |
Class Method Details
.parse(raw_ical) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/calagator/vcalendar.rb', line 5 def self.parse(raw_ical) raw_ical.gsub! /\r\n/, "\n" # normalize line endings raw_ical.gsub! /;TZID=GMT:(.*)/, ':\1Z' # normalize timezones RiCal.parse_string(raw_ical).map do |ri_cal_calendar| VCalendar.new(ri_cal_calendar) end rescue Exception => exception return false if exception. =~ /Invalid icalendar file/ # Invalid data, give up. raise # Unknown error, reraise end |
Instance Method Details
#vevents ⇒ Object
18 19 20 21 22 |
# File 'lib/calagator/vcalendar.rb', line 18 def vevents ri_cal_calendar.events.map do |ri_cal_event| VEvent.new(ri_cal_event, vvenues) end end |
#vvenues ⇒ Object
26 27 28 29 30 |
# File 'lib/calagator/vcalendar.rb', line 26 def vvenues @vvenues ||= ri_cal_calendar.to_s.scan(VENUE_CONTENT_RE).map do |raw_ical_venue| VVenue.new(raw_ical_venue) end end |