Class: BootstrapCalendarHelper::BootstrapCalendar
- Inherits:
-
Struct
- Object
- Struct
- BootstrapCalendarHelper::BootstrapCalendar
- Defined in:
- app/helpers/bootstrap_calendar_helper.rb
Constant Summary collapse
- HEADER =
%w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
- START_DAY =
:sunday
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#date ⇒ Object
Returns the value of attribute date.
-
#view ⇒ Object
Returns the value of attribute view.
Instance Method Summary collapse
- #calendar_div ⇒ Object
- #day_cell(day) ⇒ Object
- #day_classes(day) ⇒ Object
- #header ⇒ Object
- #week_rows ⇒ Object
- #weeks ⇒ Object
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback
6 7 8 |
# File 'app/helpers/bootstrap_calendar_helper.rb', line 6 def callback @callback end |
#date ⇒ Object
Returns the value of attribute date
6 7 8 |
# File 'app/helpers/bootstrap_calendar_helper.rb', line 6 def date @date end |
#view ⇒ Object
Returns the value of attribute view
6 7 8 |
# File 'app/helpers/bootstrap_calendar_helper.rb', line 6 def view @view end |
Instance Method Details
#calendar_div ⇒ Object
12 13 14 15 16 |
# File 'app/helpers/bootstrap_calendar_helper.rb', line 12 def calendar_div content_tag 'div', class: "calendar_grid" do header + week_rows end end |
#day_cell(day) ⇒ Object
34 35 36 |
# File 'app/helpers/bootstrap_calendar_helper.rb', line 34 def day_cell(day) content_tag :div, view.capture(day, &callback), class: day_classes(day) end |
#day_classes(day) ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/helpers/bootstrap_calendar_helper.rb', line 38 def day_classes(day) classes = ['span1'] classes << "today" if day == Date.today classes << "notmonth" if day.month != date.month classes << "month" if day.month == date.month classes.empty? ? nil : classes.join(" ") end |
#header ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/bootstrap_calendar_helper.rb', line 18 def header content_tag 'div', class: 'month_header row-fluid' do HEADER.map { |day| content_tag :div, class: 'span1' do day end }.join.html_safe end end |
#week_rows ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/helpers/bootstrap_calendar_helper.rb', line 26 def week_rows weeks.map {|week| content_tag :div, class: 'row-fluid week' do week.map { |day| day_cell(day) }.join.html_safe end }.join.html_safe end |