Borges::BatchedList (Class)

In: lib/Borges/Component/BatchedList.rb
Parent: Object

A BatchedList paginates a list of items.

The user must render the currently displayed list and the page bar.

Example:

class MyList < Borges::Component

  def initialize(items)
    @batcher = Borges::BatchedList.new(items)
  end

  def choose(item)
    call(MyView.new(item)) # MyView is a component that views the item.
  end

  def renderContentOn(r)
    r.list_do(@batcher.batch) do |item|
      r.anchor(item.title do choose(item) end
    end

    r.render(@batcher)
  end

end

Constants

DEFAULT_SIZE = 10

Attributes

batch_size  [RW] 
current_page  [RW] 
items  [RW] 

Public Class methods

Create a new BatchedList from items, with size items per page.

Public Instance methods

The batch of items on the current page

The index of the last item from the batch on the current page.

The maximum number of pages (indexed from 1)

Move to the next page in the batch.

Is the first page in the batch being displayed?

Is the last page in the batch being displayed?

Move to the previous page in the batch.

Render the page selector for the batch.

You must supply your own code to render the contents of the batch. See StoreItemList for an example.

The index of the first item from the batch on the current page.

[Validate]