Class: RubyUI::DataTableManualAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_ui/data_table/data_table_manual_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DataTableManualAdapter.



7
8
9
10
11
# File 'lib/ruby_ui/data_table/data_table_manual_adapter.rb', line 7

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.



5
6
7
# File 'lib/ruby_ui/data_table/data_table_manual_adapter.rb', line 5

def current_page
  @current_page
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



5
6
7
# File 'lib/ruby_ui/data_table/data_table_manual_adapter.rb', line 5

def per_page
  @per_page
end

#total_countObject (readonly)

Returns the value of attribute total_count.



5
6
7
# File 'lib/ruby_ui/data_table/data_table_manual_adapter.rb', line 5

def total_count
  @total_count
end

Instance Method Details

#total_pagesObject



13
14
15
# File 'lib/ruby_ui/data_table/data_table_manual_adapter.rb', line 13

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