Class Webby::Paginator::Page
In: lib/webby/stelan/paginator.rb
Parent: Object

Page object

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

Methods

each   first_item_number   items   last_item_number   next   next?   prev   prev?  

Included Modules

Enumerable

Attributes

number  [R] 
pager  [R] 
url  [R] 

Public Instance methods

[Source]

# File lib/webby/stelan/paginator.rb, line 150
    def each(&block)
      items.each(&block)
    end

The "item number" of the first item on this page

[Source]

# File lib/webby/stelan/paginator.rb, line 133
    def first_item_number
      1 + @offset
    end

Retrieve the items for this page

  • Caches

[Source]

# File lib/webby/stelan/paginator.rb, line 108
    def items
      @items ||= @select.call
    end

The "item number" of the last item on this page

[Source]

# File lib/webby/stelan/paginator.rb, line 138
    def last_item_number
      if next?
        @offset + @pager.per_page
      else
        @pager.count
      end
    end

Get next page (if possible)

[Source]

# File lib/webby/stelan/paginator.rb, line 128
    def next
      @pager.page(@number + 1) if next?
    end

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

[Source]

# File lib/webby/stelan/paginator.rb, line 123
    def next?
      @number < @pager.number_of_pages
    end

Get previous page (if possible)

[Source]

# File lib/webby/stelan/paginator.rb, line 118
    def prev
      @pager.page(@number - 1) if prev?
    end

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

[Source]

# File lib/webby/stelan/paginator.rb, line 113
    def prev?
      @number > 1
    end

[Validate]