# File lib/thinking_sphinx/masks/pagination_mask.rb, line 2 def initialize(search) @search = search end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 6 def can_handle?(method) public_methods(false).include?(method) end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 10 def first_page? search.current_page == 1 end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 14 def last_page? next_page.nil? end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 18 def next_page search.current_page >= total_pages ? nil : search.current_page + 1 end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 22 def next_page? !next_page.nil? end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 26 def page(number) search.options[:page] = number search end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 31 def per(limit) search.options[:limit] = limit search end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 36 def previous_page search.current_page == 1 ? nil : search.current_page - 1 end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 40 def total_entries search.meta['total_found'].to_i end
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 47 def total_pages return 0 if search.meta['total'].nil? @total_pages ||= (search.meta['total'].to_i / search.per_page.to_f).ceil end