Class: ActionController::Pagination::Paginator::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/pagination.rb

Overview

A class for representing ranges around a given page.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, padding = 2) ⇒ Window

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



377
378
379
380
381
# File 'lib/pagination.rb', line 377

def initialize(page, padding=2)
  @paginator = page.paginator
  @page = page
  self.padding = padding
end

Instance Attribute Details

#firstObject (readonly)

Returns the value of attribute first.



394
395
396
# File 'lib/pagination.rb', line 394

def first
  @first
end

#lastObject (readonly)

Returns the value of attribute last.



394
395
396
# File 'lib/pagination.rb', line 394

def last
  @last
end

#paddingObject

Returns the value of attribute padding.



394
395
396
# File 'lib/pagination.rb', line 394

def padding
  @padding
end

#pageObject (readonly)

Returns the value of attribute page.



382
383
384
# File 'lib/pagination.rb', line 382

def page
  @page
end

#paginatorObject (readonly)

Returns the value of attribute paginator.



382
383
384
# File 'lib/pagination.rb', line 382

def paginator
  @paginator
end

Instance Method Details

#pagesObject Also known as: to_a

Returns an array of Page objects in the current window.



397
398
399
# File 'lib/pagination.rb', line 397

def pages
  (@first.number..@last.number).to_a.collect! {|n| @paginator[n]}
end