Class: Tanker::Pagination::Kaminari
- Inherits:
-
Array
- Object
- Array
- Tanker::Pagination::Kaminari
- Includes:
- Kaminari::ConfigurationMethods::ClassMethods, Kaminari::PageScopeMethods
- Defined in:
- lib/tanker/pagination/kaminari.rb
Instance Attribute Summary collapse
-
#limit_value ⇒ Object
readonly
Returns the value of attribute limit_value.
-
#offset_value ⇒ Object
readonly
Returns the value of attribute offset_value.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
Class Method Summary collapse
Instance Method Summary collapse
- #current_page ⇒ Object
-
#initialize(original_array, limit_val, offset_val, total_count) ⇒ Kaminari
constructor
A new instance of Kaminari.
- #limit(num) ⇒ Object
- #page(num = 1) ⇒ Object
Constructor Details
#initialize(original_array, limit_val, offset_val, total_count) ⇒ Kaminari
Returns a new instance of Kaminari.
13 14 15 16 17 |
# File 'lib/tanker/pagination/kaminari.rb', line 13 def initialize(original_array, limit_val, offset_val, total_count) @limit_value = limit_val || default_per_page @offset_value, @total_count = offset_val, total_count super(original_array) end |
Instance Attribute Details
#limit_value ⇒ Object (readonly)
Returns the value of attribute limit_value.
11 12 13 |
# File 'lib/tanker/pagination/kaminari.rb', line 11 def limit_value @limit_value end |
#offset_value ⇒ Object (readonly)
Returns the value of attribute offset_value.
11 12 13 |
# File 'lib/tanker/pagination/kaminari.rb', line 11 def offset_value @offset_value end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
11 12 13 |
# File 'lib/tanker/pagination/kaminari.rb', line 11 def total_count @total_count end |
Class Method Details
.create(results, total_hits, options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/tanker/pagination/kaminari.rb', line 32 def create(results, total_hits, = {}) instance = new(results, [:per_page], [:page]-1, total_hits) instance end |
Instance Method Details
#current_page ⇒ Object
27 28 29 |
# File 'lib/tanker/pagination/kaminari.rb', line 27 def current_page offset_value+1 end |
#limit(num) ⇒ Object
23 24 25 |
# File 'lib/tanker/pagination/kaminari.rb', line 23 def limit(num) self end |
#page(num = 1) ⇒ Object
19 20 21 |
# File 'lib/tanker/pagination/kaminari.rb', line 19 def page(num = 1) self end |