Class: Trubl::Pagination
- Inherits:
-
Object
- Object
- Trubl::Pagination
- Defined in:
- lib/trubl/pagination.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
Returns the value of attribute current_page.
-
#order ⇒ Object
Returns the value of attribute order.
-
#page ⇒ Object
Returns the value of attribute page.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#total_entries ⇒ Object
Returns the value of attribute total_entries.
Instance Method Summary collapse
Instance Attribute Details
#current_page ⇒ Object
Returns the value of attribute current_page.
3 4 5 |
# File 'lib/trubl/pagination.rb', line 3 def current_page @current_page end |
#order ⇒ Object
Returns the value of attribute order.
3 4 5 |
# File 'lib/trubl/pagination.rb', line 3 def order @order end |
#page ⇒ Object
Returns the value of attribute page.
3 4 5 |
# File 'lib/trubl/pagination.rb', line 3 def page @page end |
#per_page ⇒ Object
Returns the value of attribute per_page.
3 4 5 |
# File 'lib/trubl/pagination.rb', line 3 def per_page @per_page end |
#total_entries ⇒ Object
Returns the value of attribute total_entries.
3 4 5 |
# File 'lib/trubl/pagination.rb', line 3 def total_entries @total_entries end |
Instance Method Details
#from_response(response) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/trubl/pagination.rb', line 5 def from_response(response) pagination = pagination_from_response(response) %(order current_page per_page page total_entries).each do |attr| self.send("#{attr}=", pagination[attr]) end self end |
#pagination_from_response(response) ⇒ Object
13 14 15 |
# File 'lib/trubl/pagination.rb', line 13 def pagination_from_response(response) JSON.parse(response.body)["pagination"] end |