Sha256: 868516785e2dc41129ff867b11730172de1971bfa0d2bab5bd99436eaa53a683
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
module Clever module APIOperations # Handles paginated requests. class PageList include Enumerable # Create a new PageList, without making any requests immediately # @api private # @return [PageList] def initialize(uri, filters = {}) @uri = uri @filters = filters end # Iterate through each page, making requests as you iterate # @api private # @return [nil] # @example # pagelist.each do |page| # page.each do |elem| # puts elem # end # end def each page = Page.new @uri, @filters until page.nil? yield page page = page.next end end # Convert PageList into a ResultsList for easier iteration # @api private # @return [Clever::APIOperations::ResultsList] # @example # pagelist.to_results_list.each { |elem| puts elem } def to_results_list Clever::APIOperations::ResultsList.new self end end end end
Version data entries
4 entries across 4 versions & 1 rubygems