Module: CloudSearchRails::Search::WillPaginateMethods

Defined in:
lib/cloud_search_rails/search.rb

Overview

methods of WillPaginate compatibility

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_pageObject

Returns the value of attribute current_page.



25
26
27
# File 'lib/cloud_search_rails/search.rb', line 25

def current_page
  @current_page
end

#per_pageObject

Returns the value of attribute per_page.



25
26
27
# File 'lib/cloud_search_rails/search.rb', line 25

def per_page
  @per_page
end

#total_entriesObject

Returns the value of attribute total_entries.



25
26
27
# File 'lib/cloud_search_rails/search.rb', line 25

def total_entries
  @total_entries
end

Instance Method Details

#offsetObject

calculated offset given the current page and the number of entries per page



29
30
31
# File 'lib/cloud_search_rails/search.rb', line 29

def offset
  (self.current_page - 1) * self.per_page
end

#total_pagesObject

total number of pages



34
35
36
# File 'lib/cloud_search_rails/search.rb', line 34

def total_pages
  (self.total_entries.to_f / self.per_page.to_f).ceil
end