class QoolifeApi::PaginatedCollection
Attributes
first_page[RW]
last_page[RW]
next_page[RW]
prev_page[RW]
Public Class Methods
new(elements = [])
click to toggle source
# File lib/qoolife-api/paginated_collection.rb, line 5 def initialize(elements = []) @elements = elements response = QoolifeApi::Base.connection.http_response response = pagination_header_response_to_hash response['Link'] @first_page = response[:first] @prev_page = response[:prev] @next_page = response[:next] @last_page = response[:last] end
Private Instance Methods
pagination_header_response_to_hash(response)
click to toggle source
# File lib/qoolife-api/paginated_collection.rb, line 17 def pagination_header_response_to_hash(response) response.to_s.split(',').each_with_object({}) do |item, h| items = item.split(';') key = items.last.gsub('rel=', '').gsub("\"", '').to_sym value = items.first h[key] = value end end