module Icalendar::Google::Helpers

Attributes

google_id[RW]
ical_url[RW]

Public Instance Methods

cid() click to toggle source
# File lib/icalendar/google/helpers.rb, line 10
def cid
  Base64.encode64(@google_id.to_s).gsub(%r{\n|=+\Z}, "")
end
eid(event) click to toggle source
# File lib/icalendar/google/helpers.rb, line 14
def eid(event)
  seed = "#{event.uid.split(%r{@}).first} #{@google_id&.slice(0, 28)}"
  Base64.encode64(seed).gsub(%r{\n|=+\Z}, "")
end
event_url(event) click to toggle source
# File lib/icalendar/google/helpers.rb, line 19
def event_url(event)
  "https://calendar.google.com/calendar/event?eid=#{eid(event)}"
end
events_on(date) click to toggle source
# File lib/icalendar/google/helpers.rb, line 23
def events_on(date)
  events.select do |event|
    start = tz.utc_to_local event.dtstart.to_datetime
    stop  = tz.utc_to_local event.dtend.to_datetime
    start.to_date <= date && date <= stop.to_date
  end
end
google_url() click to toggle source
# File lib/icalendar/google/helpers.rb, line 31
def google_url
  "https://calendar.google.com/calendar/r?cid=#{cid}"
end
tz() click to toggle source
# File lib/icalendar/google/helpers.rb, line 35
def tz
  TZInfo::Timezone.get(x_wr_timezone.first.to_s)
end
webcal_url() click to toggle source
# File lib/icalendar/google/helpers.rb, line 39
def webcal_url
  ical_url&.sub(%r{\Ahttps?://}, "webcal://")
end