Class: SmartPaginate::Paginate
- Inherits:
-
Object
- Object
- SmartPaginate::Paginate
- Defined in:
- lib/smart_paginate/paginate.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
Instance Method Summary collapse
-
#initialize(current_page, per_page = nil) ⇒ Paginate
constructor
A new instance of Paginate.
- #offset ⇒ Object
Constructor Details
#initialize(current_page, per_page = nil) ⇒ Paginate
5 6 7 8 |
# File 'lib/smart_paginate/paginate.rb', line 5 def initialize(current_page, per_page = nil) @current_page = convert(current_page, 1) @per_page = convert(per_page, 20) end |
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
3 4 5 |
# File 'lib/smart_paginate/paginate.rb', line 3 def current_page @current_page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
3 4 5 |
# File 'lib/smart_paginate/paginate.rb', line 3 def per_page @per_page end |
Instance Method Details
#offset ⇒ Object
10 11 12 |
# File 'lib/smart_paginate/paginate.rb', line 10 def offset (current_page - 1) * per_page end |