A class for representing ranges around a given page.
Methods
Attributes
[R] | first | |
[R] | last | |
[R] | padding | |
[R] | page | |
[R] | paginator |
Class Public methods
Creates a new Window object for the given
page
with the specified padding
.
Source: show
# File rails/actionpack/lib/action_controller/pagination.rb, line 380 def initialize(page, padding=2) @paginator = page.paginator @page = page self.padding = padding end
Instance Public methods
Sets the window’s padding (the number of pages on either side of the window page).
Source: show
# File rails/actionpack/lib/action_controller/pagination.rb, line 389 def padding=(padding) @padding = padding < 0 ? 0 : padding # Find the beginning and end pages of the window @first = @paginator.has_page_number?(@page.number - @padding) ? @paginator[@page.number - @padding] : @paginator.first @last = @paginator.has_page_number?(@page.number + @padding) ? @paginator[@page.number + @padding] : @paginator.last end