Class: Almanack::Calendar

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/almanack/calendar.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Calendar

Returns a new instance of Calendar.



11
12
13
# File 'lib/almanack/calendar.rb', line 11

def initialize(config)
  @config = config
end

Instance Method Details

#eventsObject



15
16
17
18
19
# File 'lib/almanack/calendar.rb', line 15

def events
  now = Time.now
  future = now + days_lookahead * ONE_DAY
  events_between(now..future)
end

#events_between(date_range) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/almanack/calendar.rb', line 21

def events_between(date_range)
  event_list = event_sources.map do |event_source|
    Thread.new { event_source.events_between(date_range) }
  end.map(&:value).flatten

  event_list.sort_by do |event|
    event.start_time.to_time
  end
end

#ical_feedObject



31
32
33
# File 'lib/almanack/calendar.rb', line 31

def ical_feed
  Representation::IcalFeed.from(self).to_s
end

#json_feedObject



35
36
37
# File 'lib/almanack/calendar.rb', line 35

def json_feed
  Representation::JSONFeed.from(self).to_s
end