Class: StompBase::Ui::PaginationComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/stomp_base/ui/pagination_component.rb

Instance Method Summary collapse

Methods inherited from BaseComponent

#call, #render?

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

Returns:

  • (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_offsetObject



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

Returns:

  • (Boolean)


15
16
17
# File 'app/components/stomp_base/ui/pagination_component.rb', line 15

def pagination?
  @total_pages > 1
end

#previous_page?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/components/stomp_base/ui/pagination_component.rb', line 19

def previous_page?
  @current_page > 1
end

#previous_page_offsetObject



27
28
29
# File 'app/components/stomp_base/ui/pagination_component.rb', line 27

def previous_page_offset
  (@current_page - 2) * @per_page
end