Class: Sunspot::NullResult::PaginatedNullArray
- Inherits:
-
Array
- Object
- Array
- Sunspot::NullResult::PaginatedNullArray
- Defined in:
- lib/sunspot/null_result.rb
Overview
Implements the interface of github.com/sunspot/sunspot/blob/master/sunspot_rails/lib/sunspot/rails/stub_session_proxy.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#per_page ⇒ Object
(also: #limit_value)
readonly
Returns the value of attribute per_page.
Instance Method Summary collapse
- #first_page? ⇒ Boolean
-
#initialize(collection, current_page: 1, per_page: 1) ⇒ PaginatedNullArray
constructor
A new instance of PaginatedNullArray.
- #last_page? ⇒ Boolean
- #next_page ⇒ Object
- #offset ⇒ Object
- #out_of_bounds? ⇒ Boolean
- #previous_page ⇒ Object
- #total_pages ⇒ Object (also: #num_pages)
Constructor Details
#initialize(collection, current_page: 1, per_page: 1) ⇒ PaginatedNullArray
Returns a new instance of PaginatedNullArray.
21 22 23 24 25 |
# File 'lib/sunspot/null_result.rb', line 21 def initialize(collection, current_page: 1, per_page: 1) super(collection) @current_page = current_page @per_page = per_page end |
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
19 20 21 |
# File 'lib/sunspot/null_result.rb', line 19 def current_page @current_page end |
#per_page ⇒ Object (readonly) Also known as: limit_value
Returns the value of attribute per_page.
19 20 21 |
# File 'lib/sunspot/null_result.rb', line 19 def per_page @per_page end |
Instance Method Details
#first_page? ⇒ Boolean
44 45 46 |
# File 'lib/sunspot/null_result.rb', line 44 def first_page? true end |
#last_page? ⇒ Boolean
48 49 50 |
# File 'lib/sunspot/null_result.rb', line 48 def last_page? true end |
#next_page ⇒ Object
40 41 42 |
# File 'lib/sunspot/null_result.rb', line 40 def next_page (current_page+1) if total_pages > current_page end |
#offset ⇒ Object
56 57 58 |
# File 'lib/sunspot/null_result.rb', line 56 def offset 0 end |
#out_of_bounds? ⇒ Boolean
52 53 54 |
# File 'lib/sunspot/null_result.rb', line 52 def out_of_bounds? false end |
#previous_page ⇒ Object
36 37 38 |
# File 'lib/sunspot/null_result.rb', line 36 def previous_page (current_page-1) if current_page > 1 end |
#total_pages ⇒ Object Also known as: num_pages
30 31 32 |
# File 'lib/sunspot/null_result.rb', line 30 def total_pages [(size/per_page.to_f).ceil, 1].max end |