Sha256: 2a94f7eb4a6562bce3e0a60db0820193b61c1b4d9151ef4a69856c706e032a17

Contents?: true

Size: 817 Bytes

Versions: 18

Compression:

Stored size: 817 Bytes

Contents

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

require_relative 'month_mixin'

class Pagy # :nodoc:
  class Calendar # :nodoc:
    # Calendar quarter subclass
    class Quarter < Calendar
      DEFAULT = { order:  :asc,      # rubocop:disable Style/MutableConstant
                  format: '%Y-Q%q' } # '%q' token
      MONTHS  = 3  # number of months of the unit
      include MonthMixin

      # The label for any page, with the substitution of the '%q' token
      def label_for(page, opts = {})
        starting_time = starting_time_for(page.to_i)  # page could be a string
        opts[:format] = (opts[:format] || @vars[:format]).gsub('%q') { (starting_time.month / 4) + 1 }
        localize(starting_time, opts)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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