module Indexers::Pagination

Public Instance Methods

first_page() click to toggle source
# File lib/indexers/pagination.rb, line 16
def first_page
  1
end
last_page() click to toggle source
# File lib/indexers/pagination.rb, line 20
def last_page
  total_pages
end
next_page() click to toggle source
# File lib/indexers/pagination.rb, line 12
def next_page
  @next_page ||= (current_page < total_pages ? (current_page + 1) : nil)
end
out_of_bounds?() click to toggle source
# File lib/indexers/pagination.rb, line 24
def out_of_bounds?
  @out_of_bounds ||= (current_page > total_pages || current_page < first_page)
end
previous_page() click to toggle source
# File lib/indexers/pagination.rb, line 8
def previous_page
  @previous_page ||= (current_page > 1 ? (current_page - 1) : nil)
end
total_count() click to toggle source
# File lib/indexers/pagination.rb, line 28
def total_count
  @total_count ||= (response['hits']['total'].to_i - padding)
end
total_pages() click to toggle source
# File lib/indexers/pagination.rb, line 4
def total_pages
  @total_pages ||= [(total_count.to_f / page_length).ceil, 1].max
end