Class: MrCommon::Reminder

Inherits:
ApplicationRecord show all
Defined in:
app/models/mr_common/reminder.rb

Overview

Stores information for generating downloadable calendar reminders that appear in some emails.

When

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.search(q) ⇒ Object



38
39
40
41
# File 'app/models/mr_common/reminder.rb', line 38

def self.search(q)
  qy = "%#{q}%"
  Reminder.where("summary ilike ? or description ilike ? or project_number ilike ?", qy, qy, qy)
end

Instance Method Details

#to_icalObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/mr_common/reminder.rb', line 23

def to_ical
  cal = Icalendar::Calendar.new

  cal.add_timezone(TZInfo::Timezone.get(time_zone).ical_timezone(start_time))
  cal.event do |e|
    e.dtstart = calendar_start_time
    e.dtend = calendar_end_time
    e.summary = summary
    e.location = location
    e.description = description
  end
  cal.publish
  cal.to_ical
end