Class: CalendarHelper::CalendarBuilder
- Inherits:
-
TableHelper::TableBuilder
- Object
- TableHelper::TableBuilder
- CalendarHelper::CalendarBuilder
- Defined in:
- lib/table_builder/calendar_helper.rb
Instance Method Summary collapse
- #day(*args) ⇒ Object
-
#initialize(objects, template, calendar, options) ⇒ CalendarBuilder
constructor
A new instance of CalendarBuilder.
Methods inherited from TableHelper::TableBuilder
#body, #body_r, #d, #h, #head, #head_r, #r
Constructor Details
#initialize(objects, template, calendar, options) ⇒ CalendarBuilder
Returns a new instance of CalendarBuilder.
24 25 26 27 28 29 |
# File 'lib/table_builder/calendar_helper.rb', line 24 def initialize(objects, template, calendar, ) super(objects, template, ) @calendar = calendar.new() @today = [:today] || Time.now @row_header = [:row_header] || false end |
Instance Method Details
#day(*args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/table_builder/calendar_helper.rb', line 31 def day(*args) raise ArgumentError, "Missing block" unless block_given? = (args) day_method = .delete(:day_method) || :date id_pattern = .delete(:id) tbody do @calendar.objects_for_days(@objects, day_method).to_a.sort{|a1, a2| a1.first <=> a2.first }.each do |o| key, array = o day, objects = array concat(tag(:tr, , true)) if(day.wday == @calendar.first_weekday) if @row_header && day.wday == @calendar.first_weekday = (day, id_pattern) [:class] ||= "" [:class] << " row_header" concat(tag(:td, , true)) yield(day, nil) concat("</td>") end concat(tag(:td, (day, id_pattern), true)) yield(day, objects) concat('</td>') concat('</tr>') if(day.wday == @calendar.last_weekday) end end end |