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.
9 10 11 12 13 14 15 |
# File 'lib/rs_paginator/collection.rb', line 9 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.
7 8 9 |
# File 'lib/rs_paginator/collection.rb', line 7 def page @page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
7 8 9 |
# File 'lib/rs_paginator/collection.rb', line 7 def per_page @per_page end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
7 8 9 |
# File 'lib/rs_paginator/collection.rb', line 7 def total @total end |
Instance Method Details
#total_pages ⇒ Object
17 18 19 |
# File 'lib/rs_paginator/collection.rb', line 17 def total_pages (@total.to_f / @per_page).ceil end |