A class representing a single page in a paginator.

Methods
Included Modules
Attributes
[R] number
[R] paginator
Public Class methods
new(paginator, number)

Creates a new Page for the given paginator with the index number. If number is not in the range of valid page numbers or is not a number at all, it defaults to 1.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 297
297:         def initialize(paginator, number)
298:           @paginator = paginator
299:           @number = number.to_i
300:           @number = 1 unless @paginator.has_page_number? @number
301:         end
Public Instance methods
<=>(page)

Compares two Page objects and returns -1 if the left-hand page comes before the right-hand page, 0 if the pages are equal, and 1 if the left-hand page comes after the right-hand page. Raises ArgumentError if the pages do not belong to the same Paginator object.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 318
318:         def <=>(page)
319:           raise ArgumentError unless @paginator == page.paginator
320:           @number <=> page.number
321:         end
==(page)

Compares two Page objects and returns true when they represent the same page (i.e., their paginators are the same and they have the same page number).

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 308
308:         def ==(page)
309:           return false if page.nil?
310:           @paginator == page.paginator and 
311:             @number == page.number
312:         end
first?()

Returns true if this page is the first page in the paginator.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 339
339:         def first?
340:           self == @paginator.first
341:         end
first_item()

Returns the number of the first item displayed.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 329
329:         def first_item
330:           offset + 1
331:         end
last?()

Returns true if this page is the last page in the paginator.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 344
344:         def last?
345:           self == @paginator.last
346:         end
last_item()

Returns the number of the last item displayed.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 334
334:         def last_item
335:           [@paginator.items_per_page * @number, @paginator.item_count].min
336:         end
next()

Returns a new Page object representing the page just after this page, or nil if this is the last page.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 356
356:         def next
357:           if last? then nil else @paginator[@number + 1] end
358:         end
offset()

Returns the item offset for the first item in this page.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 324
324:         def offset
325:           @paginator.items_per_page * (@number - 1)
326:         end
previous()

Returns a new Page object representing the page just before this page, or nil if this is the first page.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 350
350:         def previous
351:           if first? then nil else @paginator[@number - 1] end
352:         end
to_sql()

Returns the limit/offset array for this page.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 367
367:         def to_sql
368:           [@paginator.items_per_page, offset]
369:         end
window(padding=2)

Returns a new Window object for this page with the specified padding.

     # File vendor/rails/actionpack/lib/action_controller/pagination.rb, line 362
362:         def window(padding=2)
363:           Window.new(self, padding)
364:         end