diff --git a/app/models/course.rb b/app/models/course.rb index 1272ef5..d40b0c6 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -18,14 +18,15 @@ class Course < ApplicationRecord calendar = calendars.first events = calendar.events.map do |event| + # Example title include: PH40065B-Lab, PH40112-Lecc (Wk 19-25, 29-32), MA40049-Leca (LOIL), MA40049-Lecb summary = event.summary - match = summary.split('-') + match = /(^\w\w\d{5})-(\w+)/.match(summary) # Handle odd events we don't care about - next if match.length != 2 + next if match.nil? - unit_code = match[0] - short_lecture_title = match[1] + unit_code = match[1] + short_lecture_title = match[2] start_time = event.dtstart.to_time event_uuid = event.uid.to_s