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

Constants

DEFAULT_ENV = 5

Attributes

environment  [RW] 

Public Class methods

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

Public Instance methods

Render the page selector for the batch.

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

[Validate]