Class: EventDb::EventCalendar

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/eventdb/calendar.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ EventCalendar

Returns a new instance of EventCalendar.



54
55
56
# File 'lib/eventdb/calendar.rb', line 54

def initialize( opts={} )
  @events    = opts[:events] || Event.order('start_date DESC')   ## sort events by date (newest first)
end

Instance Method Details

#eventsObject



58
59
60
61
# File 'lib/eventdb/calendar.rb', line 58

def events
  ## note: return new cursor  -- use decorator (instead of extra loop arg, why? why not?
  EventCursor.new( @events )
end

#render(opts = {}) ⇒ Object



63
64
65
66
67
68
# File 'lib/eventdb/calendar.rb', line 63

def render( opts={} )
  tmpl_path  = opts[:template] || './templates/CALENDAR.md.erb'
  tmpl       = File.open( tmpl_path, 'r:utf-8' ).read

  ERB.new( tmpl, nil, '<>' ).result( binding )   # <> omit newline for lines starting with <% and ending in %>
end