Sha256: 5dfddf28a02f3c042ec74e2081d040df738047f575b2ccbf9f5623547217654f

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 Bytes

Contents

# See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar
# frozen_string_literal: true

class Pagy # :nodoc:
  class Calendar # :nodoc:
    # Calendar year subclass
    class Year < Calendar
      DEFAULT = { order:  :asc,      # rubocop:disable Style/MutableConstant
                  format: '%Y' }

      protected

      # Setup the calendar variables
      def setup_unit_vars
        super
        @initial = new_time(@starting.year)
        @final   = new_time(@ending.year + 1)
        @pages   = @last = @final.year - @initial.year
        @from    = start_for(@page)
        @to      = new_time(@from.year + 1)
      end

      # Time for the page
      def start_for(page)
        new_time(@initial.year + snap(page))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pagy-5.6.1 lib/pagy/calendar/year.rb
pagy-5.6.0 lib/pagy/calendar/year.rb
pagy-5.5.1 lib/pagy/calendar/year.rb