class Collection
Attributes
client[RW]
response[RW]
Public Class Methods
new(client, response)
click to toggle source
# File lib/collection.rb, line 5 def initialize(client, response) @client = client @response = response @pagination_links = [] set_pagination end
Public Instance Methods
each(&block)
click to toggle source
# File lib/collection.rb, line 12 def each(&block) @response[0].each(&block) end
next()
click to toggle source
# File lib/collection.rb, line 47 def next url = parse_pagination_link(@pagination_links) self.response = self.client.http_req(URI(url), 'GET', {}) self.set_pagination return self.response end
pages_remain()
click to toggle source
# File lib/collection.rb, line 23 def pages_remain pages_remaining = nil for link in @pagination_links #latter conditional is in here for now because logs pagination is entering infinite loop and currently unsure why if (link.include? 'rel="next') and (self.response[0] != []) pages_remaining = true end end return pages_remaining end
parse_pagination_link(links)
click to toggle source
# File lib/collection.rb, line 36 def parse_pagination_link(links) url = nil for link in links if link.include? 'rel="next' url = (link.split(';')[0]).gsub(/[< >]/, '') end end return url end
set_pagination()
click to toggle source
# File lib/collection.rb, line 16 def set_pagination # Checks for non-nil value in 1st indice. If pagination exists, this value will exist if self.response[1] @pagination_links = self.response[1].split(',') end end