Class: SimpleCalendar::WeekCalendar
- Inherits:
-
Calendar
- Object
- Calendar
- SimpleCalendar::WeekCalendar
show all
- Defined in:
- lib/simple_calendar/week_calendar.rb
Instance Attribute Summary
Attributes inherited from Calendar
#block, #events, #options, #view_context
Instance Method Summary
collapse
Methods inherited from Calendar
#default_td_classes, #default_thead, #events_for_date, #get_option, #initialize, #param_name, #render, #render_header, #render_table, #render_week, #render_weeks, #start_date
Instance Method Details
#date_range ⇒ Object
3
4
5
6
7
8
9
10
11
|
# File 'lib/simple_calendar/week_calendar.rb', line 3
def date_range
@date_range ||= begin
number_of_weeks = options.fetch(:number_of_weeks, 1)
number_of_days = (number_of_weeks * 7) - 1
starting_day = start_date.beginning_of_week.to_date
ending_day = starting_day + number_of_days.days
starting_day..ending_day
end
end
|
#default_next_link ⇒ Object
31
32
33
|
# File 'lib/simple_calendar/week_calendar.rb', line 31
def default_next_link
->(param, date_range) { link_to raw("»"), param => date_range.last + 1.day }
end
|
#default_previous_link ⇒ Object
27
28
29
|
# File 'lib/simple_calendar/week_calendar.rb', line 27
def default_previous_link
->(param, date_range) { link_to raw("«"), param => date_range.first - (((options.fetch(:number_of_weeks, 1) - 1) * 7) + 1).days }
end
|
#default_title ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/simple_calendar/week_calendar.rb', line 13
def default_title
->(start_date) { content_tag :span,
if month_name(@date_range.last) == month_name(start_date)
month_name(start_date) .
concat year_number(start_date)
else
month_name(start_date) .
concat " into " .
concat month_name(@date_range.last) .
concat year_number @date_range.last
end
}
end
|
#month_name(date) ⇒ Object
35
36
37
|
# File 'lib/simple_calendar/week_calendar.rb', line 35
def month_name(date)
"#{I18n.t("date.month_names")[date.month]}"
end
|
#year_number(date) ⇒ Object
39
40
41
|
# File 'lib/simple_calendar/week_calendar.rb', line 39
def year_number(date)
" #{date.year}"
end
|