lib/pagy.rb in pagy-6.2.0 vs lib/pagy.rb in pagy-6.3.0
- old
+ new
@@ -3,28 +3,28 @@
require 'pathname'
# Core class
class Pagy
- VERSION = '6.2.0'
+ VERSION = '6.3.0'
# Root pathname to get the path of Pagy files like templates or dictionaries
def self.root
@root ||= Pathname.new(__dir__).freeze
end
# Default core vars: constant for easy access, but mutable for customizable defaults
- DEFAULT = { page: 1, # rubocop:disable Style/MutableConstant
- items: 20,
- outset: 0,
- size: [1, 4, 4, 1],
- page_param: :page,
- params: {},
- fragment: '',
- link_extra: '',
- i18n_key: 'pagy.item_name',
- cycle: false,
+ DEFAULT = { page: 1, # rubocop:disable Style/MutableConstant
+ items: 20,
+ outset: 0,
+ size: [1, 4, 4, 1],
+ page_param: :page,
+ params: {},
+ fragment: '',
+ link_extra: '',
+ i18n_key: 'pagy.item_name',
+ cycle: false,
request_path: '' }
attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :in, :from, :to, :prev, :next, :params, :request_path
# Merge and validate the options, do some simple arithmetic and set the instance variables
@@ -36,14 +36,14 @@
setup_offset_var
setup_params_var
setup_request_path_var
raise OverflowError.new(self, :page, "in 1..#{@last}", @page) if @page > @last
- @from = [@offset - @outset + 1, @count].min
- @to = [@offset - @outset + @items, @count].min
- @in = [@to - @from + 1, @count].min
- @prev = (@page - 1 unless @page == 1)
- @next = @page == @last ? (1 if @vars[:cycle]) : @page + 1
+ @from = [@offset - @outset + 1, @count].min
+ @to = [@offset - @outset + @items, @count].min
+ @in = [@to - @from + 1, @count].min
+ @prev = (@page - 1 unless @page == 1)
+ @next = @page == @last ? (1 if @vars[:cycle]) : @page + 1
end
# Return the array of page numbers and :gap items e.g. [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
def series(size: @vars[:size], **_)
return [] if size.empty?