Class: SimpleCalendar::WeekCalendar
- Inherits:
-
Calendar
- Object
- Calendar
- SimpleCalendar::WeekCalendar
show all
- Defined in:
- lib/simple_calendar/week_calendar.rb
Constant Summary
Constants inherited
from Calendar
Calendar::PARAM_KEY_BLACKLIST
Instance Attribute Summary
Attributes inherited from Calendar
#options, #view_context
Instance Method Summary
collapse
Methods inherited from Calendar
#additional_days, #attribute, #end_attribute, #end_date, #group_events_by_date, #initialize, #locals, #partial_name, #render_in, #sorted_events, #sorted_events_for, #start_date, #start_date_param, #td_classes_for, #tr_classes_for, #url_for_next_view, #url_for_today_view
Instance Method Details
#date_range ⇒ Object
16
17
18
19
20
21
|
# File 'lib/simple_calendar/week_calendar.rb', line 16
def date_range
starting = start_date.beginning_of_week
ending = (starting + (number_of_weeks - 1).weeks).end_of_week
(starting..ending).to_a
end
|
#end_week ⇒ Object
12
13
14
|
# File 'lib/simple_calendar/week_calendar.rb', line 12
def end_week
week_number + number_of_weeks - 1
end
|
#number_of_weeks ⇒ Object
8
9
10
|
# File 'lib/simple_calendar/week_calendar.rb', line 8
def number_of_weeks
options.fetch(:number_of_weeks, 1)
end
|
#url_for_previous_view ⇒ Object
23
24
25
|
# File 'lib/simple_calendar/week_calendar.rb', line 23
def url_for_previous_view
view_context.url_for(@params.merge(start_date_param => (date_range.first - 1.day).iso8601))
end
|
#week_number ⇒ Object
3
4
5
6
|
# File 'lib/simple_calendar/week_calendar.rb', line 3
def week_number
format = (Date.beginning_of_week == :sunday) ? "%U" : "%V"
start_date.beginning_of_week.strftime(format).to_i
end
|