class Almanack::Representation::IcalFeed

Attributes

calendar[R]

Public Class Methods

from(calendar) click to toggle source
# File lib/almanack/representation/ical_feed.rb, line 18
def self.from(calendar)
  self.new(calendar)
end
new(calendar) click to toggle source
# File lib/almanack/representation/ical_feed.rb, line 6
def initialize(calendar)
  @calendar = calendar
end

Public Instance Methods

ical() click to toggle source
# File lib/almanack/representation/ical_feed.rb, line 10
def ical
  @ical ||= ical_calendar
end
to_s() click to toggle source
# File lib/almanack/representation/ical_feed.rb, line 14
def to_s
  ical.to_ical
end

Private Instance Methods

events() click to toggle source
# File lib/almanack/representation/ical_feed.rb, line 24
def events
  calendar.events_between(now..lookahead)
end
ical_calendar() click to toggle source
# File lib/almanack/representation/ical_feed.rb, line 28
def ical_calendar
  events.each_with_object(Icalendar::Calendar.new) do |event, calendar|
    calendar.add_event ical_event_for(event)
  end
end
ical_event_for(event) click to toggle source
# File lib/almanack/representation/ical_feed.rb, line 34
def ical_event_for(event)
  BuiltIcalEvent.for(event)
end
lookahead() click to toggle source
# File lib/almanack/representation/ical_feed.rb, line 38
def lookahead
  now + calendar.feed_lookahead * ONE_DAY
end
now() click to toggle source
# File lib/almanack/representation/ical_feed.rb, line 42
def now
  @now ||= Time.now
end