Class: StompBase::Ui::PaginationComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- StompBase::Ui::PaginationComponent
- Defined in:
- app/components/stomp_base/ui/pagination_component.rb
Instance Method Summary collapse
-
#initialize(model_name:, current_page:, total_pages:, per_page:, total_count:) ⇒ PaginationComponent
constructor
A new instance of PaginationComponent.
- #next_page? ⇒ Boolean
- #next_page_offset ⇒ Object
- #pagination? ⇒ Boolean
- #previous_page? ⇒ Boolean
- #previous_page_offset ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(model_name:, current_page:, total_pages:, per_page:, total_count:) ⇒ PaginationComponent
Returns a new instance of PaginationComponent.
6 7 8 9 10 11 12 13 |
# File 'app/components/stomp_base/ui/pagination_component.rb', line 6 def initialize(model_name:, current_page:, total_pages:, per_page:, total_count:) super() @model_name = model_name @current_page = current_page @total_pages = total_pages @per_page = per_page @total_count = total_count end |
Instance Method Details
#next_page? ⇒ Boolean
23 24 25 |
# File 'app/components/stomp_base/ui/pagination_component.rb', line 23 def next_page? @current_page < @total_pages end |
#next_page_offset ⇒ Object
31 32 33 |
# File 'app/components/stomp_base/ui/pagination_component.rb', line 31 def next_page_offset @current_page * @per_page end |
#pagination? ⇒ Boolean
15 16 17 |
# File 'app/components/stomp_base/ui/pagination_component.rb', line 15 def pagination? @total_pages > 1 end |
#previous_page? ⇒ Boolean
19 20 21 |
# File 'app/components/stomp_base/ui/pagination_component.rb', line 19 def previous_page? @current_page > 1 end |
#previous_page_offset ⇒ Object
27 28 29 |
# File 'app/components/stomp_base/ui/pagination_component.rb', line 27 def previous_page_offset (@current_page - 2) * @per_page end |