Module: Tinia::Search::WillPaginateMethods

Defined in:
lib/tinia/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.



21
22
23
# File 'lib/tinia/search.rb', line 21

def current_page
  @current_page
end

#per_pageObject

Returns the value of attribute per_page.



21
22
23
# File 'lib/tinia/search.rb', line 21

def per_page
  @per_page
end

#total_entriesObject

Returns the value of attribute total_entries.



21
22
23
# File 'lib/tinia/search.rb', line 21

def total_entries
  @total_entries
end

Instance Method Details

#next_pageObject

the next page number



24
25
26
# File 'lib/tinia/search.rb', line 24

def next_page
  self.current_page + 1
end

#offsetObject

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



30
31
32
# File 'lib/tinia/search.rb', line 30

def offset
  self.previous_page * self.per_page
end

#previous_pageObject

the previous page number



35
36
37
# File 'lib/tinia/search.rb', line 35

def previous_page
  self.current_page - 1
end

#total_pagesObject

total number of pages



40
41
42
# File 'lib/tinia/search.rb', line 40

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