class ThinkingSphinx::Masks::PaginationMask

Attributes

Public Class Methods

new(search) click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 2
def initialize(search)
  @search = search
end

Public Instance Methods

can_handle?(method) click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 6
def can_handle?(method)
  public_methods(false).include?(method)
end
count()
Alias for: total_entries
first_page?() click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 10
def first_page?
  search.current_page == 1
end
last_page?() click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 14
def last_page?
  next_page.nil?
end
next_page() click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 18
def next_page
  search.current_page >= total_pages ? nil : search.current_page + 1
end
next_page?() click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 22
def next_page?
  !next_page.nil?
end
num_pages()
Alias for: total_pages
page(number) click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 26
def page(number)
  search.options[:page] = number
  search
end
page_count()
Alias for: total_pages
per(limit) click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 31
def per(limit)
  search.options[:limit] = limit
  search
end
prev_page()
Alias for: previous_page
previous_page() click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 36
def previous_page
  search.current_page == 1 ? nil : search.current_page - 1
end
Also aliased as: prev_page
total_count()
Alias for: total_entries
total_entries() click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 42
def total_entries
  search.meta['total_found'].to_i
end
Also aliased as: total_count, count
total_pages() click to toggle source
# File lib/thinking_sphinx/masks/pagination_mask.rb, line 49
def total_pages
  return 0 if search.meta['total'].nil?

  @total_pages ||= (search.meta['total'].to_i / search.per_page.to_f).ceil
end
Also aliased as: page_count, num_pages