Class: RsPaginator::Collection
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- RsPaginator::Collection
- Includes:
- Enumerable
- Defined in:
- lib/rs_paginator/collection.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(objects, page, per_page, total) ⇒ Collection
constructor
A new instance of Collection.
- #total_pages ⇒ Object
Constructor Details
#initialize(objects, page, per_page, total) ⇒ Collection
Returns a new instance of Collection.
7 8 9 10 11 12 13 |
# File 'lib/rs_paginator/collection.rb', line 7 def initialize(objects, page, per_page, total) @objects = objects @page = page.to_i @per_page = per_page.to_i @total = total.to_i super(objects) end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
5 6 7 |
# File 'lib/rs_paginator/collection.rb', line 5 def page @page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
5 6 7 |
# File 'lib/rs_paginator/collection.rb', line 5 def per_page @per_page end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
5 6 7 |
# File 'lib/rs_paginator/collection.rb', line 5 def total @total end |
Instance Method Details
#total_pages ⇒ Object
15 16 17 |
# File 'lib/rs_paginator/collection.rb', line 15 def total_pages (@total.to_f / @per_page).ceil end |