Class: Borges::BigBatchedList

# Borges::BigBatchedList (Class)

In: | lib/Borges/Component/BigBatchedList.rb
Parent: | Object

A BigBatchedList paginates a list of items; as opposed to the simple BatchedList, this class only displays an environment of N pages to be accessed directly around the current one.

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

Example:

      class MyList < Borges::Component
        def initialize(items)
          @batcher = Borges::BigBatchedList.new(items, 5)
        end

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

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

          r.render(@batcher)
        end
      end

## Methods

new render_content_on should_display?

## Constants

DEFAULT_ENV | = | 5

## Attributes

environment | [RW] |

## Public Class methods

new(items = [], size = DEFAULT_SIZE, environment = DEFAULT_ENV)

Create a new BigBatchedList from `items`, with `size` items per page, and links `environment` immediately surrounding pages.

## Public Instance methods

render_content_on(r)

Render the page selector for the batch.

should_display?(n)

Decides if the page number n is displayed, given current page and environment size.

[Validate]