lib/pagy.rb in pagy-5.3.1 vs lib/pagy.rb in pagy-5.4.0
- old
+ new
@@ -3,11 +3,11 @@
require 'pathname'
# Core class
class Pagy
- VERSION = '5.3.1'
+ VERSION = '5.4.0'
# Root pathname to get the path of Pagy files like templates or dictionaries
def self.root
@root ||= Pathname.new(__dir__).freeze
end
@@ -42,10 +42,10 @@
@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])
+ def series(size: @vars[:size])
return [] if size.empty?
raise VariableError.new(self, :size, 'to contain 4 items >= 0', size) \
unless size.is_a?(Array) && size.size == 4 && size.all? { |num| !num.negative? rescue false } # rubocop:disable Style/RescueModifier
# This algorithm is up to ~5x faster and ~2.3x lighter than the previous one (pagy < 4.3)