Class: SolidErrors::ApplicationController::Page
- Inherits:
-
Object
- Object
- SolidErrors::ApplicationController::Page
- Defined in:
- app/controllers/solid_errors/application_controller.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
-
#next ⇒ Object
readonly
Returns the value of attribute next.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#prev ⇒ Object
readonly
Returns the value of attribute prev.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(collection, params) ⇒ Page
constructor
A new instance of Page.
Constructor Details
#initialize(collection, params) ⇒ Page
Returns a new instance of Page.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/solid_errors/application_controller.rb', line 13 def initialize(collection, params) @count = collection.count @items = (params[:items] || 20).to_i @pages = [(@count.to_f / @items).ceil, 1].max @page = ((page = (params[:page] || 1).to_i) > @pages) ? @pages : page @first = (1 unless @page == 1) @last = (@pages unless @page == @pages) @prev = (@page - 1 unless @page == 1) @next = (@page == @pages) ? nil : @page + 1 @offset = (@items * (@page - 1)) @from = [@offset + 1, @count].min @to = [@offset + @items, @count].min end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def count @count end |
#first ⇒ Object (readonly)
Returns the value of attribute first.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def first @first end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def from @from end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def items @items end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def last @last end |
#next ⇒ Object (readonly)
Returns the value of attribute next.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def next @next end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def offset @offset end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def pages @pages end |
#prev ⇒ Object (readonly)
Returns the value of attribute prev.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def prev @prev end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
11 12 13 |
# File 'app/controllers/solid_errors/application_controller.rb', line 11 def to @to end |