class Sunspot::Search::PaginatedCollection
Attributes
current_page[R]
limit_value[R]
per_page[R]
total_count[RW]
total_entries[RW]
total_entries=[RW]
Public Class Methods
new(collection, page, per_page, total)
click to toggle source
# File lib/sunspot/search/paginated_collection.rb, line 12 def initialize(collection, page, per_page, total) @current_page = page @per_page = per_page @total_count = total replace collection end
Public Instance Methods
first_page?()
click to toggle source
# File lib/sunspot/search/paginated_collection.rb, line 24 def first_page? current_page == 1 end
last_page?()
click to toggle source
# File lib/sunspot/search/paginated_collection.rb, line 28 def last_page? current_page >= total_pages end
next_page()
click to toggle source
# File lib/sunspot/search/paginated_collection.rb, line 37 def next_page current_page < total_pages ? (current_page + 1) : nil end
offset()
click to toggle source
# File lib/sunspot/search/paginated_collection.rb, line 45 def offset (current_page - 1) * per_page end
Also aliased as: offset_value
out_of_bounds?()
click to toggle source
# File lib/sunspot/search/paginated_collection.rb, line 41 def out_of_bounds? current_page > total_pages end
previous_page()
click to toggle source
# File lib/sunspot/search/paginated_collection.rb, line 32 def previous_page current_page > 1 ? (current_page - 1) : nil end
Also aliased as: prev_page
total_pages()
click to toggle source
# File lib/sunspot/search/paginated_collection.rb, line 19 def total_pages (total_count.to_f / per_page).ceil end
Also aliased as: num_pages