Class: Paginator::Page
- Inherits:
-
Object
- Object
- Paginator::Page
- Extended by:
- Forwardable
- Defined in:
- lib/active_scaffold/paginator.rb,
lib/active_scaffold/extensions/paginator_extensions.rb
Overview
Page object
Retrieves items for a page and provides metadata about the position of the page in the paginator
Instance Attribute Summary (collapse)
-
- (Object) number
readonly
Returns the value of attribute number.
-
- (Object) pager
readonly
Returns the value of attribute pager.
Instance Method Summary (collapse)
-
- (Object) ==(other)
:nodoc:.
-
- (Object) first_item_number
The "item number" of the first item on this page.
-
- (Page) initialize(pager, number, select)
constructor
:nodoc:.
-
- (Object) items
Retrieve the items for this page
-
Caches.
-
-
- (Object) last_item_number
The "item number" of the last item on this page.
-
- (Object) next
Get next page (if possible).
-
- (Boolean) next?
Checks to see if there's a page after this one.
-
- (Boolean) next_with_infinite?
Checks to see if there's a page after this one.
-
- (Object) prev
Get previous page (if possible).
-
- (Boolean) prev?
Checks to see if there's a page before this one.
Constructor Details
- (Page) initialize(pager, number, select)
:nodoc:
84 85 86 87 88 |
# File 'lib/active_scaffold/paginator.rb', line 84 def initialize(pager, number, select) #:nodoc: @pager, @number = pager, number @offset = (number - 1) * pager.per_page @select = select end |
Instance Attribute Details
- (Object) number (readonly)
Returns the value of attribute number
82 83 84 |
# File 'lib/active_scaffold/paginator.rb', line 82 def number @number end |
- (Object) pager (readonly)
Returns the value of attribute pager
82 83 84 |
# File 'lib/active_scaffold/paginator.rb', line 82 def pager @pager end |
Instance Method Details
- (Object) ==(other)
:nodoc:
130 131 132 |
# File 'lib/active_scaffold/paginator.rb', line 130 def ==(other) #:nodoc: @pager == other.pager && self.number == other.number end |
- (Object) first_item_number
The "item number" of the first item on this page
117 118 119 |
# File 'lib/active_scaffold/paginator.rb', line 117 def first_item_number 1 + @offset end |
- (Object) items
Retrieve the items for this page
-
Caches
92 93 94 |
# File 'lib/active_scaffold/paginator.rb', line 92 def items @items ||= @select.call end |
- (Object) last_item_number
The "item number" of the last item on this page
122 123 124 125 126 127 128 |
# File 'lib/active_scaffold/paginator.rb', line 122 def last_item_number if next? @offset + @pager.per_page else @pager.count end end |
- (Object) next
Get next page (if possible)
112 113 114 |
# File 'lib/active_scaffold/paginator.rb', line 112 def next @pager.page(@number + 1) if next? end |
- (Boolean) next?
Checks to see if there's a page after this one
107 108 109 |
# File 'lib/active_scaffold/paginator.rb', line 107 def next? @number < @pager.number_of_pages end |
- (Boolean) next_with_infinite?
Checks to see if there's a page after this one
18 19 20 21 |
# File 'lib/active_scaffold/extensions/paginator_extensions.rb', line 18 def next_with_infinite? return true if @pager.infinite? next_without_infinite? end |
- (Object) prev
Get previous page (if possible)
102 103 104 |
# File 'lib/active_scaffold/paginator.rb', line 102 def prev @pager.page(@number - 1) if prev? end |
- (Boolean) prev?
Checks to see if there's a page before this one
97 98 99 |
# File 'lib/active_scaffold/paginator.rb', line 97 def prev? @number > 1 end |