Class: Azeroth::RequestHandler::Pagination Private
- Inherits:
-
Object
- Object
- Azeroth::RequestHandler::Pagination
- Defined in:
- lib/azeroth/request_handler/pagination.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Wrapper for request finding pagination attributes
Instance Method Summary collapse
-
#current_page ⇒ Integer
private
calculates current page.
-
#initialize(params, options) ⇒ Pagination
constructor
private
A new instance of Pagination.
-
#limit ⇒ Integer
private
limit used in pagination.
-
#offset ⇒ Integer
private
offest used in pagination.
Constructor Details
#initialize(params, options) ⇒ Pagination
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Pagination.
9 10 11 12 |
# File 'lib/azeroth/request_handler/pagination.rb', line 9 def initialize(params, ) @params = params @options = end |
Instance Method Details
#current_page ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
calculates current page
44 45 46 |
# File 'lib/azeroth/request_handler/pagination.rb', line 44 def current_page (params[:page] || 1).to_i end |
#limit ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
limit used in pagination
limit is retrieved from params[:page]
35 36 37 |
# File 'lib/azeroth/request_handler/pagination.rb', line 35 def limit (params[:per_page] || per_page).to_i end |
#offset ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
offest used in pagination
offset is retrieved from params[:per_page]
or options.per_page
24 25 26 |
# File 'lib/azeroth/request_handler/pagination.rb', line 24 def offset (current_page - 1) * limit end |