Module: ElasticSearch::Api::Pagination
- Included in:
- Hits
- Defined in:
- lib/elasticsearch/client/hits.rb
Instance Method Summary collapse
- #current_page ⇒ Object
- #next_page ⇒ Object
- #per_page ⇒ Object
- #previous_page ⇒ Object
- #total_pages ⇒ Object (also: #page_count)
Instance Method Details
#current_page ⇒ Object
22 23 24 |
# File 'lib/elasticsearch/client/hits.rb', line 22 def current_page (@options[:page].respond_to?(:empty?) ? @options[:page].empty? : !@options[:page]) ? 1 : @options[:page].to_i end |
#next_page ⇒ Object
26 27 28 |
# File 'lib/elasticsearch/client/hits.rb', line 26 def next_page current_page >= total_pages ? nil : current_page + 1 end |
#per_page ⇒ Object
34 35 36 |
# File 'lib/elasticsearch/client/hits.rb', line 34 def per_page @options[:per_page] || 10 end |
#previous_page ⇒ Object
30 31 32 |
# File 'lib/elasticsearch/client/hits.rb', line 30 def previous_page current_page == 1 ? nil : current_page - 1 end |
#total_pages ⇒ Object Also known as: page_count
38 39 40 |
# File 'lib/elasticsearch/client/hits.rb', line 38 def total_pages (total_entries / per_page.to_f).ceil end |