Class: SimpleCalendar::WeekCalendar

Inherits:
Calendar
  • Object
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

#initialize, #render, #td_classes_for, #tr_classes_for, #url_for_next_view, #url_for_previous_view

Constructor Details

This class inherits a constructor from SimpleCalendar::Calendar

Instance Method Details

#date_rangeObject



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_weekObject



12
13
14
# File 'lib/simple_calendar/week_calendar.rb', line 12

def end_week
  week_number + number_of_weeks - 1
end

#number_of_weeksObject



8
9
10
# File 'lib/simple_calendar/week_calendar.rb', line 8

def number_of_weeks
  options.fetch(:number_of_weeks, 1)
end

#week_numberObject



3
4
5
6
# File 'lib/simple_calendar/week_calendar.rb', line 3

def week_number
  format = (Date.beginning_of_week == :sunday) ? "%U" : "%W"
  start_date.beginning_of_week.strftime(format).to_i
end