Class: Sidekiq::Tasks::Web::Pagination

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/tasks/web/pagination.rb

Constant Summary collapse

PREV_LABEL =
"«".freeze
NEXT_LABEL =
"»".freeze
ELLIPSIS_LABEL =
"...".freeze
MIN_PAGE_DISPLAY =
7
PAGE_OFFSET =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_page, total_pages) ⇒ Pagination

Returns a new instance of Pagination.



13
14
15
16
# File 'lib/sidekiq/tasks/web/pagination.rb', line 13

def initialize(current_page, total_pages)
  @current_page = current_page
  @total_pages = total_pages
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



11
12
13
# File 'lib/sidekiq/tasks/web/pagination.rb', line 11

def current_page
  @current_page
end

#total_pagesObject (readonly)

Returns the value of attribute total_pages.



11
12
13
# File 'lib/sidekiq/tasks/web/pagination.rb', line 11

def total_pages
  @total_pages
end

Instance Method Details



18
19
20
21
22
# File 'lib/sidekiq/tasks/web/pagination.rb', line 18

def links
  return [] if total_pages <= 1

  build_links.flatten.compact
end