Class: PhlexKit::DataTableManualAdapter

Inherits:
Object
  • Object
show all
Defined in:
app/components/phlex_kit/data_table/data_table_manual_adapter.rb

Overview

Adapter for plain page/per_page/total_count pagination (no gem). Not a component — just the current_page/total_pages interface PhlexKit::DataTablePagination consumes. Ported from ruby_ui.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page:, per_page:, total_count:) ⇒ DataTableManualAdapter

Returns a new instance of DataTableManualAdapter.



8
9
10
11
12
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 8

def initialize(page:, per_page:, total_count:)
  @current_page = page.to_i
  @per_page = [ per_page.to_i, 1 ].max
  @total_count = total_count.to_i
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



6
7
8
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 6

def current_page
  @current_page
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



6
7
8
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 6

def per_page
  @per_page
end

#total_countObject (readonly)

Returns the value of attribute total_count.



6
7
8
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 6

def total_count
  @total_count
end

Instance Method Details

#total_pagesObject



14
15
16
# File 'app/components/phlex_kit/data_table/data_table_manual_adapter.rb', line 14

def total_pages
  [ (@total_count.to_f / @per_page).ceil, 1 ].max
end