Class: Card::Set::Abstract::Paging::PagingLinks

Inherits:
Object
  • Object
show all
Defined in:
tmpsets/set/mod008-pointer/abstract/01_paging/paging_links.rb

Overview

render paging links

Instance Method Summary collapse

Constructor Details

#initialize(total_pages, current_page) ⇒ PagingLinks

Returns a new instance of PagingLinks.



11
12
13
14
# File 'tmpsets/set/mod008-pointer/abstract/01_paging/paging_links.rb', line 11

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>)


24
25
26
27
# File 'tmpsets/set/mod008-pointer/abstract/01_paging/paging_links.rb', line 24

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