class NgrokAPI::PagedIterator
Low level class which allows the user to iterate through the results of a list API call
Attributes
client[R]
list_property[R]
n[RW]
page[RW]
Public Class Methods
new( client:, page:, list_property:, danger: false )
click to toggle source
# File lib/ngrokapi/paged_iterator.rb, line 10 def initialize( client:, page:, list_property:, danger: false ) @n = 0 @client = client @list_property = list_property @page = page @danger = danger end
Public Instance Methods
get_next()
click to toggle source
Iterate through the result set, returning the next instance if we already have one, or make a new API call to next_page_uri to get more results and return the next one from that call.
@return [object] Returns an instance of a class.
# File lib/ngrokapi/paged_iterator.rb, line 28 def get_next item = @page.attrs[@list_property][@n] raise "None" if item.nil? self.n += 1 item rescue if @page.next_page_uri res = @client.list(danger: @danger, url: @page.next_page_uri) self.n = 0 self.page = res get_next end end