Class: ElasticSearchable::Pagination::Kaminari
- Inherits:
-
ElasticSearchable::Paginator
- Object
- Array
- ElasticSearchable::Paginator
- ElasticSearchable::Pagination::Kaminari
- Defined in:
- lib/elastic_searchable/pagination/kaminari.rb
Instance Attribute Summary collapse
-
#limit_value ⇒ Object
(also: #per_page)
Returns the value of attribute limit_value.
-
#page ⇒ Object
(also: #current_page)
Returns the value of attribute page.
-
#total_entries ⇒ Object
Returns the value of attribute total_entries.
-
#total_pages ⇒ Object
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#first_page? ⇒ Boolean
First page of the collection ?.
-
#initialize(results, page, per_page, total = nil) ⇒ Kaminari
constructor
A new instance of Kaminari.
-
#last_page? ⇒ Boolean
Last page of the collection?.
-
#num_pages ⇒ Object
Total number of pages.
-
#total_count ⇒ Object
total item numbers of the original array.
Methods inherited from ElasticSearchable::Paginator
Constructor Details
#initialize(results, page, per_page, total = nil) ⇒ Kaminari
Returns a new instance of Kaminari.
6 7 8 9 10 11 |
# File 'lib/elastic_searchable/pagination/kaminari.rb', line 6 def initialize(results, page, per_page, total = nil) self.page = page self.limit_value = per_page self.total_entries = total if total self.replace results end |
Instance Attribute Details
#limit_value ⇒ Object Also known as: per_page
Returns the value of attribute limit_value.
4 5 6 |
# File 'lib/elastic_searchable/pagination/kaminari.rb', line 4 def limit_value @limit_value end |
#page ⇒ Object Also known as: current_page
Returns the value of attribute page.
4 5 6 |
# File 'lib/elastic_searchable/pagination/kaminari.rb', line 4 def page @page end |
#total_entries ⇒ Object
Returns the value of attribute total_entries.
4 5 6 |
# File 'lib/elastic_searchable/pagination/kaminari.rb', line 4 def total_entries @total_entries end |
#total_pages ⇒ Object
Returns the value of attribute total_pages.
4 5 6 |
# File 'lib/elastic_searchable/pagination/kaminari.rb', line 4 def total_pages @total_pages end |
Instance Method Details
#first_page? ⇒ Boolean
First page of the collection ?
27 28 29 |
# File 'lib/elastic_searchable/pagination/kaminari.rb', line 27 def first_page? current_page == 1 end |
#last_page? ⇒ Boolean
Last page of the collection?
32 33 34 |
# File 'lib/elastic_searchable/pagination/kaminari.rb', line 32 def last_page? current_page >= num_pages end |
#num_pages ⇒ Object
Total number of pages
22 23 24 |
# File 'lib/elastic_searchable/pagination/kaminari.rb', line 22 def num_pages (total_count.to_f / per_page).ceil end |
#total_count ⇒ Object
total item numbers of the original array
17 18 19 |
# File 'lib/elastic_searchable/pagination/kaminari.rb', line 17 def total_count total_entries end |