Class: Card::PagingLinks

Inherits:
Object show all
Defined in:
mod/collection/lib/card/paging_links.rb

Overview

generates pagination links

Constant Summary collapse

MAX_PAGES =
100

Instance Method Summary collapse

Constructor Details

#initialize(total_pages, current_page) ⇒ PagingLinks

Returns a new instance of PagingLinks.



6
7
8
9
# File 'mod/collection/lib/card/paging_links.rb', line 6

def initialize total_pages, current_page
  @total = total_pages
  @current = current_page
end

Instance Method Details

#build(window = 2) {|text, page, status, options| ... } ⇒ Array<String>

@example: current page = 5, window = 2 |«|1|…|3|4|[5]|6|7|…|10|»|

Parameters:

  • window (integer) (defaults to: 2)

    number of page links shown left and right of the current page

Yields:

  • (text, page, status, options)

    block to build single paging link

Yield Parameters:

  • status (Symbol)

    :active (for current page) or :disabled

  • page (Integer)

    page number, first page is 0

Returns:

  • (Array<String>)


19
20
21
22
# File 'mod/collection/lib/card/paging_links.rb', line 19

def build window=2, &block
  @render_item = block
  links window
end