Sha256: 40f15fbdc8861b2bd852cf7cbf2b89c14906f760b7520ded75722985dc5d92a9
Contents?: true
Size: 466 Bytes
Versions: 1
Compression:
Stored size: 466 Bytes
Contents
require 'geared_pagination/ratios' module GearedPagination class Portion attr_reader :page_number, :ratios def initialize(page_number: 1, per_page: GearedPagination::Ratios.new) @page_number, @ratios = page_number, per_page end def from(scope) scope.limit(limit).offset(offset) end def limit ratios[page_number] end def offset (page_number - 1).times.sum { |index| ratios[index + 1] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geared_pagination-0.1 | lib/geared_pagination/portion.rb |