Class: RubyUI::DataTableManualAdapter
- Inherits:
-
Object
- Object
- RubyUI::DataTableManualAdapter
- Defined in:
- lib/ruby_ui/data_table/data_table_manual_adapter.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
Instance Method Summary collapse
-
#initialize(page:, per_page:, total_count:) ⇒ DataTableManualAdapter
constructor
A new instance of DataTableManualAdapter.
- #total_pages ⇒ Object
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_page ⇒ Object (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_page ⇒ Object (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_count ⇒ Object (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_pages ⇒ Object
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 |