Class: Wor::Paginate::Adapters::Base
- Inherits:
-
Object
- Object
- Wor::Paginate::Adapters::Base
- Defined in:
- lib/wor/paginate/adapters/base.rb
Direct Known Subclasses
MockedAdapter, ActiveRecord, Enumerable, Kaminari, KaminariAlreadyPaginated, WillPaginate, WillPaginateAlreadyPaginated
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #adapt? ⇒ Boolean
-
#initialize(content, page, limit) ⇒ Base
constructor
A new instance of Base.
- #next_page ⇒ Object
- #previous_page ⇒ Object
Constructor Details
#initialize(content, page, limit) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 |
# File 'lib/wor/paginate/adapters/base.rb', line 7 def initialize(content, page, limit) @content = content @page = page.to_i @limit = limit.to_i raise Wor::Paginate::Exceptions::InvalidPageNumber if @page <= 0 raise Wor::Paginate::Exceptions::InvalidLimitNumber if @limit <= 0 end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
5 6 7 |
# File 'lib/wor/paginate/adapters/base.rb', line 5 def page @page end |
Instance Method Details
#adapt? ⇒ Boolean
15 16 17 |
# File 'lib/wor/paginate/adapters/base.rb', line 15 def adapt? required_methods.all? { |method| @content.respond_to? method } end |
#next_page ⇒ Object
25 26 27 28 29 |
# File 'lib/wor/paginate/adapters/base.rb', line 25 def next_page return nil if page >= total_pages page + 1 end |
#previous_page ⇒ Object
31 32 33 34 35 |
# File 'lib/wor/paginate/adapters/base.rb', line 31 def previous_page return nil if page == 1 page - 1 end |