Sha256: b750a5029f898a7682053856549e49f45c362eb02a89d9a4e996a01b7810b78c

Contents?: true

Size: 821 Bytes

Versions: 4

Compression:

Stored size: 821 Bytes

Contents

module SimpleCalendar
  class WeekCalendar < Calendar
    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

    def default_previous_link
      ->(param, date_range) { link_to raw("&laquo;"), param => date_range.first - (((options.fetch(:number_of_weeks, 1) - 1) * 7) + 1).days }
    end

    def default_next_link
      ->(param, date_range) { link_to raw("&raquo;"), param => date_range.last + 1.day }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_calendar-1.1.4 lib/simple_calendar/week_calendar.rb
simple_calendar-1.1.3 lib/simple_calendar/week_calendar.rb
simple_calendar-1.1.2 lib/simple_calendar/week_calendar.rb
simple_calendar-1.1.1 lib/simple_calendar/week_calendar.rb