Module: CalendarHelper
- Defined in:
- lib/ical/calendar_helper.rb
Defined Under Namespace
Classes: Calendar, CalendarBuilder
Instance Method Summary collapse
-
#calendar_for(objects, *args) ⇒ Object
Generates a calendar (as a table) for an array of objects placing each of them on the corresponding date.
Instance Method Details
#calendar_for(objects, *args) ⇒ Object
Generates a calendar (as a table) for an array of objects placing each of them on the corresponding date. **TODO: fully document this method, the current documentation is far from done.** :row_header if true, each row will have an extra cell at the beginning, as a row header. A typical usage would be to output week numbers. When the block is called, it will get the date that would normally be passed to the first day of the week (to give you some context) and a nil list of objects (and that’s how you recognize it as a header, because empty days get an empty array, not nil).
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ical/calendar_helper.rb', line 11 def calendar_for(objects, *args) raise ArgumentError, "Missing block" unless block_given? = args.last.is_a?(Hash) ? args.pop : {} = [:html] builder = [:builder] || CalendarBuilder calendar = [:calendar] || Calendar content_tag(:table, nil, ) do yield builder.new(objects || [], self, calendar, ) end end |