Class: Karafka::Web::Ui::Lib::Paginations::PageBased
- Defined in:
- lib/karafka/web/ui/lib/paginations/page_based.rb
Overview
Regular page-based pagination engine
Instance Attribute Summary
Attributes inherited from Base
#current_offset, #next_offset, #previous_offset
Instance Method Summary collapse
-
#current_label ⇒ String
Label of the current page.
-
#current_offset? ⇒ Boolean
Always show current offset pagination value.
-
#first_offset ⇒ Boolean
First page for page based pagination is always empty as it moves us to the initial page so we do not include any page info.
-
#first_offset? ⇒ Boolean
Active the first page link when we are not on the first page.
-
#initialize(current_offset, show_next_offset) ⇒ PageBased
constructor
A new instance of PageBased.
-
#next_offset? ⇒ Boolean
Move to the next page if not false.
-
#offset_key ⇒ String
For page pages pagination, always use page as the url value.
-
#paginate? ⇒ Boolean
Show pagination only when there is more than one page.
-
#previous_offset? ⇒ Boolean
Active previous page link when it is not the first page.
Constructor Details
#initialize(current_offset, show_next_offset) ⇒ PageBased
Returns a new instance of PageBased.
13 14 15 16 17 18 19 20 21 |
# File 'lib/karafka/web/ui/lib/paginations/page_based.rb', line 13 def initialize( current_offset, show_next_offset ) @previous_offset = current_offset - 1 @current_offset = current_offset @next_offset = show_next_offset ? current_offset + 1 : false super() end |
Instance Method Details
#current_label ⇒ String
Returns label of the current page.
51 52 53 |
# File 'lib/karafka/web/ui/lib/paginations/page_based.rb', line 51 def current_label @current_offset.to_s end |
#current_offset? ⇒ Boolean
Returns always show current offset pagination value.
46 47 48 |
# File 'lib/karafka/web/ui/lib/paginations/page_based.rb', line 46 def current_offset? true end |
#first_offset ⇒ Boolean
Returns first page for page based pagination is always empty as it moves us to the initial page so we do not include any page info.
36 37 38 |
# File 'lib/karafka/web/ui/lib/paginations/page_based.rb', line 36 def first_offset false end |
#first_offset? ⇒ Boolean
Returns active the first page link when we are not on the first page.
30 31 32 |
# File 'lib/karafka/web/ui/lib/paginations/page_based.rb', line 30 def first_offset? @current_offset > 1 end |
#next_offset? ⇒ Boolean
Returns move to the next page if not false. False indicates, that there is no next page to move to.
57 58 59 |
# File 'lib/karafka/web/ui/lib/paginations/page_based.rb', line 57 def next_offset? @next_offset end |
#offset_key ⇒ String
Returns for page pages pagination, always use page as the url value.
62 63 64 |
# File 'lib/karafka/web/ui/lib/paginations/page_based.rb', line 62 def offset_key 'page' end |
#paginate? ⇒ Boolean
Show pagination only when there is more than one page
25 26 27 |
# File 'lib/karafka/web/ui/lib/paginations/page_based.rb', line 25 def paginate? @current_offset && (@current_offset > 1 || !!@next_offset) end |
#previous_offset? ⇒ Boolean
Returns Active previous page link when it is not the first page.
41 42 43 |
# File 'lib/karafka/web/ui/lib/paginations/page_based.rb', line 41 def previous_offset? @current_offset > 1 end |