module Elasticsearch::Search::ViewHelpers

Public Instance Methods

lastpage(total, per_page) click to toggle source
# File app/models/elasticsearch/search.rb, line 256
def lastpage(total, per_page)
  last_page = total/per_page + 1
  if total%per_page == 0
    last_page = last_page - 1
  end  
  return last_page
end
minmaxpage(current, total_pages, option) click to toggle source
# File app/models/elasticsearch/search.rb, line 264
def minmaxpage(current, total_pages, option)
  min = current - 2
  if min < 1
    min = 1
    max = 1 + 4
    if max > total_pages then max = total_pages end
  end
  max = min + 4
  if max > total_pages
    max = total_pages
    min = max - 4
    while min < 1
      min = min + 1
    end
  end
  if option.eql?('min') then return min else return max end
end