Sha256: 243936ed83c5ab1f21d24b786bb58d80a2a30bc4ff864c45922457e29fae8cd0
Contents?: true
Size: 642 Bytes
Versions: 4
Compression:
Stored size: 642 Bytes
Contents
module Indexes module Pagination def total_pages @total_pages ||= [(total_count.to_f / page_length).ceil, 1].max end def previous_page @previous_page ||= (current_page > 1 ? (current_page - 1) : nil) end def next_page @next_page ||= (current_page < total_pages ? (current_page + 1) : nil) end def first_page 1 end def last_page total_pages end def out_of_bounds? @out_of_bounds ||= (current_page > total_pages || current_page < first_page) end def total_count @total_count ||= (response['hits']['total'].to_i - padding) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
indexes-4.0.0.2 | lib/indexes/pagination.rb |
indexes-4.0.0.1 | lib/indexes/pagination.rb |
indexes-4.0.0.0 | lib/indexes/pagination.rb |
indexes-0.0.1 | lib/indexes/pagination.rb |