Class: Trubl::Pagination

Inherits:
Object
  • Object
show all
Defined in:
lib/trubl/pagination.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_pageObject

Returns the value of attribute current_page.



3
4
5
# File 'lib/trubl/pagination.rb', line 3

def current_page
  @current_page
end

#orderObject

Returns the value of attribute order.



3
4
5
# File 'lib/trubl/pagination.rb', line 3

def order
  @order
end

#pageObject

Returns the value of attribute page.



3
4
5
# File 'lib/trubl/pagination.rb', line 3

def page
  @page
end

#per_pageObject

Returns the value of attribute per_page.



3
4
5
# File 'lib/trubl/pagination.rb', line 3

def per_page
  @per_page
end

#total_entriesObject

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