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