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.



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

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

Instance Method Details

#eventsObject



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

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

#render(opts = {}) ⇒ Object



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

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