Class: Maglev::Uikit::PaginationComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Maglev::Uikit::PaginationComponent
- Includes:
- Pagy::Frontend
- Defined in:
- app/components/maglev/uikit/pagination_component.rb
Instance Attribute Summary collapse
-
#hidden_if_single_page ⇒ Object
readonly
Returns the value of attribute hidden_if_single_page.
-
#pagy ⇒ Object
readonly
Returns the value of attribute pagy.
Instance Method Summary collapse
-
#initialize(pagy:, item_name: 'item', hidden_if_single_page: true, show_info: true) ⇒ PaginationComponent
constructor
A new instance of PaginationComponent.
- #item_name ⇒ Object
- #render? ⇒ Boolean
- #show_info? ⇒ Boolean
Methods inherited from BaseComponent
Constructor Details
#initialize(pagy:, item_name: 'item', hidden_if_single_page: true, show_info: true) ⇒ PaginationComponent
Returns a new instance of PaginationComponent.
10 11 12 13 14 15 |
# File 'app/components/maglev/uikit/pagination_component.rb', line 10 def initialize(pagy:, item_name: 'item', hidden_if_single_page: true, show_info: true) @pagy = pagy @hidden_if_single_page = hidden_if_single_page @item_name = item_name @show_info = show_info end |
Instance Attribute Details
#hidden_if_single_page ⇒ Object (readonly)
Returns the value of attribute hidden_if_single_page.
8 9 10 |
# File 'app/components/maglev/uikit/pagination_component.rb', line 8 def hidden_if_single_page @hidden_if_single_page end |
#pagy ⇒ Object (readonly)
Returns the value of attribute pagy.
8 9 10 |
# File 'app/components/maglev/uikit/pagination_component.rb', line 8 def pagy @pagy end |
Instance Method Details
#item_name ⇒ Object
17 18 19 |
# File 'app/components/maglev/uikit/pagination_component.rb', line 17 def item_name @item_name.pluralize(@pagy.count) end |
#render? ⇒ Boolean
21 22 23 |
# File 'app/components/maglev/uikit/pagination_component.rb', line 21 def render? !(hidden_if_single_page && pagy.pages < 2) end |
#show_info? ⇒ Boolean
25 26 27 |
# File 'app/components/maglev/uikit/pagination_component.rb', line 25 def show_info? @show_info end |