Module: Qyu::Helpers::Pagination

Included in:
UI
Defined in:
lib/qyu/ui/helpers/pagination.rb

Defined Under Namespace

Classes: PaginatableArray

Instance Method Summary collapse

Instance Method Details

#next_pages_for(collection) ⇒ Object


29
30
31
32
33
# File 'lib/qyu/ui/helpers/pagination.rb', line 29

def next_pages_for(collection)
  return [] if collection.page == collection.total_pages
  end_page = [collection.total_pages, collection.page + 3].min
  (collection.page + 1).upto(end_page)
end

#previous_pages_for(collection) ⇒ Object


23
24
25
26
27
# File 'lib/qyu/ui/helpers/pagination.rb', line 23

def previous_pages_for(collection)
  return [] if collection.page < 2
  start_page = [collection.page - 3, 1].max
  start_page.upto(collection.page - 1)
end