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
6 7 8 |
# File 'lib/calagator/vcalendar.rb', line 6 def ri_cal_calendar @ri_cal_calendar end |
Class Method Details
.parse(raw_ical) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/calagator/vcalendar.rb', line 8 def self.parse(raw_ical) raw_ical = raw_ical.gsub(/\r\n/, "\n") # normalize line endings raw_ical = raw_ical.gsub(/;TZID=GMT:(.*)/, ':\1Z') # normalize timezones ri_cal = RiCal.parse_string(raw_ical) ri_cal.map do |ri_cal_calendar| VCalendar.new(ri_cal_calendar) end rescue => e if /InvalidIcalendarFileError/.match?(e.) return false end # Invalid data, give up. raise # Unknown error, reraise end |
Instance Method Details
#vevents ⇒ Object
23 24 25 26 27 |
# File 'lib/calagator/vcalendar.rb', line 23 def vevents ri_cal_calendar.events.map do |ri_cal_event| VEvent.new(ri_cal_event, vvenues) end end |
#vvenues ⇒ Object
29 30 31 32 33 |
# File 'lib/calagator/vcalendar.rb', line 29 def vvenues @vvenues ||= ri_cal_calendar.to_s.scan(VENUE_CONTENT_RE).map do |raw_ical_venue| VVenue.new(raw_ical_venue) end end |