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

Inherits:
Object
  • Object
show all
Defined in:
lib/action_controller/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.



367
368
369
370
371
# File 'lib/action_controller/pagination.rb', line 367

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.



384
385
386
# File 'lib/action_controller/pagination.rb', line 384

def first
  @first
end

#lastObject (readonly)

Returns the value of attribute last.



384
385
386
# File 'lib/action_controller/pagination.rb', line 384

def last
  @last
end

#paddingObject

Returns the value of attribute padding.



384
385
386
# File 'lib/action_controller/pagination.rb', line 384

def padding
  @padding
end

#pageObject (readonly)

Returns the value of attribute page.



372
373
374
# File 'lib/action_controller/pagination.rb', line 372

def page
  @page
end

#paginatorObject (readonly)

Returns the value of attribute paginator.



372
373
374
# File 'lib/action_controller/pagination.rb', line 372

def paginator
  @paginator
end

Instance Method Details

#pagesObject Also known as: to_a

Returns an array of Page objects in the current window.



387
388
389
# File 'lib/action_controller/pagination.rb', line 387

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