Class: ActionController::Pagination::Paginator::Window
- Inherits:
-
Object
- Object
- ActionController::Pagination::Paginator::Window
- Defined in:
- lib/action_controller/pagination.rb
Overview
A class for representing ranges around a given page.
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
-
#padding ⇒ Object
Returns the value of attribute padding.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#paginator ⇒ Object
readonly
Returns the value of attribute paginator.
Instance Method Summary collapse
-
#initialize(page, padding = 2) ⇒ Window
constructor
Creates a new Window object for the given
page
with the specifiedpadding
. -
#pages ⇒ Object
(also: #to_a)
Returns an array of Page objects in the current window.
Constructor Details
#initialize(page, padding = 2) ⇒ Window
Creates a new Window object for the given page
with the specified padding
.
373 374 375 376 377 |
# File 'lib/action_controller/pagination.rb', line 373 def initialize(page, padding=2) @paginator = page.paginator @page = page self.padding = padding end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
390 391 392 |
# File 'lib/action_controller/pagination.rb', line 390 def first @first end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
390 391 392 |
# File 'lib/action_controller/pagination.rb', line 390 def last @last end |
#padding ⇒ Object
Returns the value of attribute padding.
390 391 392 |
# File 'lib/action_controller/pagination.rb', line 390 def padding @padding end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
378 379 380 |
# File 'lib/action_controller/pagination.rb', line 378 def page @page end |
#paginator ⇒ Object (readonly)
Returns the value of attribute paginator.
378 379 380 |
# File 'lib/action_controller/pagination.rb', line 378 def paginator @paginator end |
Instance Method Details
#pages ⇒ Object Also known as: to_a
Returns an array of Page objects in the current window.
393 394 395 |
# File 'lib/action_controller/pagination.rb', line 393 def pages (@first.number..@last.number).to_a.collect! {|n| @paginator[n]} end |