class BlacklightInternetArchive::Response::PaginatedDocSet
A response module which gets mixed into the ['response’] array.
Attributes
page_start[RW]
page_total[RW]
per_page[RW]
start[RW]
start=[RW]
total[RW]
total=[RW]
Public Instance Methods
current_page()
click to toggle source
Returns the current page calculated from 'rows' and 'start'
# File lib/blacklight_internet_archive/response.rb, line 51 def current_page return 1 if start < 1 per_page_normalized = per_page < 1 ? 1 : per_page @current_page ||= (start / per_page_normalized).ceil + 1 end
has_next?()
click to toggle source
# File lib/blacklight_internet_archive/response.rb, line 72 def has_next? current_page < total_pages end
has_previous?()
click to toggle source
# File lib/blacklight_internet_archive/response.rb, line 76 def has_previous? current_page > 1 end
next_page()
click to toggle source
returns the next page number or the last
# File lib/blacklight_internet_archive/response.rb, line 68 def next_page @next_page ||= current_page == total_pages ? total_pages : current_page + 1 end
previous_page()
click to toggle source
returns the previous page number or 1
# File lib/blacklight_internet_archive/response.rb, line 63 def previous_page @previous_page ||= current_page > 1 ? current_page - 1 : 1 end
total_pages()
click to toggle source
Calcuates the total pages from 'numFound' and 'rows'
# File lib/blacklight_internet_archive/response.rb, line 58 def total_pages @total_pages ||= per_page > 0 ? (total / per_page.to_f).ceil : 1 end