Sha256: 9f3b92bd09d479dd1d952393095ab8f858bc8f1114957ad6c4f49d6398fcf037

Contents?: true

Size: 822 Bytes

Versions: 17

Compression:

Stored size: 822 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    = starting_time_for(@page)
        @to      = new_time(@from.year + 1)
      end

      # Starting time for the page
      def starting_time_for(page)
        new_time(@initial.year + offset_units_for(page))
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pagy-5.8.1 lib/pagy/calendar/year.rb
pagy-5.8.0 lib/pagy/calendar/year.rb
pagy-5.7.6 lib/pagy/calendar/year.rb
pagy-5.7.5 lib/pagy/calendar/year.rb
pagy-5.7.4 lib/pagy/calendar/year.rb
pagy-5.7.3 lib/pagy/calendar/year.rb
pagy-5.7.2 lib/pagy/calendar/year.rb
pagy-5.7.1 lib/pagy/calendar/year.rb
pagy-5.7.0 lib/pagy/calendar/year.rb
pagy-5.6.10 lib/pagy/calendar/year.rb
pagy-5.6.9 lib/pagy/calendar/year.rb
pagy-5.6.8 lib/pagy/calendar/year.rb
pagy-5.6.7 lib/pagy/calendar/year.rb
pagy-5.6.6 lib/pagy/calendar/year.rb
pagy-5.6.5 lib/pagy/calendar/year.rb
pagy-5.6.4 lib/pagy/calendar/year.rb
pagy-5.6.3 lib/pagy/calendar/year.rb