Module: Tinia::Search::WillPaginateMethods
- Defined in:
- lib/tinia/search.rb
Overview
methods of WillPaginate compatibility
Instance Attribute Summary collapse
-
#current_page ⇒ Object
Returns the value of attribute current_page.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#total_entries ⇒ Object
Returns the value of attribute total_entries.
Instance Method Summary collapse
-
#next_page ⇒ Object
the next page number.
-
#offset ⇒ Object
calculated offset given the current page and the number of entries per page.
-
#previous_page ⇒ Object
the previous page number.
-
#total_pages ⇒ Object
total number of pages.
Instance Attribute Details
#current_page ⇒ Object
Returns the value of attribute current_page.
21 22 23 |
# File 'lib/tinia/search.rb', line 21 def current_page @current_page end |
#per_page ⇒ Object
Returns the value of attribute per_page.
21 22 23 |
# File 'lib/tinia/search.rb', line 21 def per_page @per_page end |
#total_entries ⇒ Object
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_page ⇒ Object
the next page number
24 25 26 |
# File 'lib/tinia/search.rb', line 24 def next_page self.current_page + 1 end |
#offset ⇒ Object
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_page ⇒ Object
the previous page number
35 36 37 |
# File 'lib/tinia/search.rb', line 35 def previous_page self.current_page - 1 end |
#total_pages ⇒ Object
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 |