class TrackerApi::Client::Pagination
Attributes
headers[RW]
limit[RW]
offset[RW]
returned[RW]
total[RW]
Public Class Methods
new(headers)
click to toggle source
# File lib/tracker_api/client.rb, line 238 def initialize(headers) @headers = headers @total = headers['x-tracker-pagination-total'].to_i @limit = headers['x-tracker-pagination-limit'].to_i @offset = headers['x-tracker-pagination-offset'].to_i @returned = headers['x-tracker-pagination-returned'].to_i # if offset is negative (e.g. Iterations Endpoint). # For the 'Done' scope, negative numbers can be passed, which # specifies the number of iterations preceding the 'Current' iteration. # then need to adjust the negative offset to account for a smaller total, # and set total to zero since we are paginating from -X to 0. if @offset < 0 @offset = -@total if @offset.abs > @total @total = 0 end end
Public Instance Methods
more?()
click to toggle source
# File lib/tracker_api/client.rb, line 256 def more? (offset + limit) < total end
next_offset()
click to toggle source
# File lib/tracker_api/client.rb, line 260 def next_offset offset + limit end
next_page_params()
click to toggle source
# File lib/tracker_api/client.rb, line 264 def next_page_params { limit: limit, offset: next_offset } end