class Paginator::Page

Page object

Retrieves items for a page and provides metadata about the position of the page in the paginator

Attributes

number[R]
pager[R]

Public Instance Methods

first_item_number() click to toggle source

The “item number” of the first item on this page

# File lib/active_scaffold/paginator.rb, line 117
def first_item_number
  1 + @offset
end
items() click to toggle source

Retrieve the items for this page

  • Caches

# File lib/active_scaffold/paginator.rb, line 92
def items
  @items ||= @select.call
end
last_item_number() click to toggle source

The “item number” of the last item on this page

# File lib/active_scaffold/paginator.rb, line 122
def last_item_number
  if next?
    @offset + @pager.per_page
  else
    @pager.count
  end
end
next() click to toggle source

Get next page (if possible)

# File lib/active_scaffold/paginator.rb, line 112
def next
  @pager.page(@number + 1) if next?
end
next?() click to toggle source

Checks to see if there’s a page after this one

# File lib/active_scaffold/paginator.rb, line 107
def next?
  @number < @pager.number_of_pages
end
next_with_infinite?() click to toggle source

Checks to see if there’s a page after this one

# File lib/active_scaffold/extensions/paginator_extensions.rb, line 18
def next_with_infinite?
  return true if @pager.infinite?
  next_without_infinite?
end
prev() click to toggle source

Get previous page (if possible)

# File lib/active_scaffold/paginator.rb, line 102
def prev
  @pager.page(@number - 1) if prev?
end
prev?() click to toggle source

Checks to see if there’s a page before this one

# File lib/active_scaffold/paginator.rb, line 97
def prev?
  @number > 1
end