Skip to content

Commit

Permalink
removed redundant condition in Pagy initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jul 13, 2018
1 parent 2e75247 commit 05729f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pagy.rb
Expand Up @@ -22,8 +22,8 @@ def initialize(vars)
(@vars[k] && instance_variable_set(:"@#{k}", @vars[k].to_i) >= min) \
or raise(ArgumentError, "expected :#{k} >= #{min}; got #{instance_variable_get(:"@#{k}").inspect}")
end
@pages = @last = [(@count.to_f / @items).ceil, 1].max # cardinal and ordinal meanings
@page >= 1 && @page <= @last or raise(OutOfRangeError.new(self), "expected :page in 1..#{@last}; got #{@page.inspect}")
@pages = @last = [(@count.to_f / @items).ceil, 1].max # cardinal and ordinal meanings
@page <= @last or raise(OutOfRangeError.new(self), "expected :page in 1..#{@last}; got #{@page.inspect}")
@offset = @items * (@page - 1) + @outset # pagination offset + outset (initial offset)
@items = @count - ((@pages-1) * @items) if @page == @last # adjust items for last page
@from = @count == 0 ? 0 : @offset+1 - @outset # page begins from item
Expand Down

0 comments on commit 05729f6

Please sign in to comment.