A class for representing ranges around a given page.

Methods
N
P
T
Attributes
[R] first
[R] last
[R] padding
[R] page
[R] paginator
Class Public methods
new(page, padding=2)

Creates a new Window object for the given page with the specified padding.

# 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
padding=(padding)

Sets the window’s padding (the number of pages on either side of the window page).

# 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
pages()

Returns an array of Page objects in the current window.

Also aliased as: to_a
# File rails/actionpack/lib/action_controller/pagination.rb, line 400
def pages
  (@first.number..@last.number).to_a.collect! {|n| @paginator[n]}
end
to_a()