Class: Aviary::Paginator
- Inherits:
-
Object
- Object
- Aviary::Paginator
- Defined in:
- lib/aviary/paginator.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Number for the current page.
-
#first_page ⇒ Object
readonly
Minimum number of pages.
-
#last_page ⇒ Object
readonly
Maximum number of pages.
-
#per_page ⇒ Object
readonly
Number of photos per page.
Instance Method Summary collapse
-
#initialize(per_page) ⇒ Paginator
constructor
A new instance of Paginator.
-
#next_page ⇒ Object
Get the page number for the next page.
-
#next_page! ⇒ Object
Get the page number for the next page and increment the
current_page
. -
#next_page? ⇒ Boolean
True if this is not the last page.
-
#prev_page ⇒ Object
Get the page number for the previous page.
-
#prev_page? ⇒ Boolean
True if this is not the first page.
- #query_options ⇒ Object
Constructor Details
Instance Attribute Details
#current_page ⇒ Object (readonly)
Number for the current page
4 5 6 |
# File 'lib/aviary/paginator.rb', line 4 def current_page @current_page end |
#first_page ⇒ Object (readonly)
Minimum number of pages
5 6 7 |
# File 'lib/aviary/paginator.rb', line 5 def first_page @first_page end |
#last_page ⇒ Object (readonly)
Maximum number of pages
6 7 8 |
# File 'lib/aviary/paginator.rb', line 6 def last_page @last_page end |
#per_page ⇒ Object (readonly)
Number of photos per page
3 4 5 |
# File 'lib/aviary/paginator.rb', line 3 def per_page @per_page end |
Instance Method Details
#next_page ⇒ Object
Get the page number for the next page.
Returns page number.
25 26 27 |
# File 'lib/aviary/paginator.rb', line 25 def next_page self.current_page + 1 end |
#next_page! ⇒ Object
Get the page number for the next page and increment the current_page
.
Returns page number.
32 33 34 |
# File 'lib/aviary/paginator.rb', line 32 def next_page! @current_page = next_page end |
#next_page? ⇒ Boolean
True if this is not the last page.
Returns boolean.
18 19 20 |
# File 'lib/aviary/paginator.rb', line 18 def next_page? self.current_page < self.last_page end |
#prev_page ⇒ Object
Get the page number for the previous page.
Returns page number.
46 47 48 |
# File 'lib/aviary/paginator.rb', line 46 def prev_page self.current_page - 1 end |
#prev_page? ⇒ Boolean
True if this is not the first page.
Returns boolean.
39 40 41 |
# File 'lib/aviary/paginator.rb', line 39 def prev_page? self.current_page > self.first_page end |
#query_options ⇒ Object
50 51 52 |
# File 'lib/aviary/paginator.rb', line 50 def {:limit => self.per_page, :offset => self.per_page * (self.current_page - 1)} end |