A class for representing ranges around a given page.
Methods
Attributes
[R] | first | |
[R] | last | |
[R] | padding | |
[R] | page | |
[R] | paginator |
Public Class methods
[ show source ]
# File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 374 374: def initialize(page, padding=2) 375: @paginator = page.paginator 376: @page = page 377: self.padding = padding 378: end
Public Instance methods
Sets the window‘s padding (the number of pages on either side of the window page).
[ show source ]
# File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 383 383: def padding=(padding) 384: @padding = padding < 0 ? 0 : padding 385: # Find the beginning and end pages of the window 386: @first = @paginator.has_page_number?(@page.number - @padding) ? 387: @paginator[@page.number - @padding] : @paginator.first 388: @last = @paginator.has_page_number?(@page.number + @padding) ? 389: @paginator[@page.number + @padding] : @paginator.last 390: end
Returns an array of Page objects in the current window.
This method is also aliased as
to_a
[ show source ]
# File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 394 394: def pages 395: (@first.number..@last.number).to_a.collect! {|n| @paginator[n]} 396: end
Alias for pages