def each
      last_page = nil
      until limit_check
        page = @block.call(last_page)
        return if page.empty?

        enumerator = if @direction == :down
                       page.each
                     elsif @direction == :up
                       page.reverse_each
                     end

        enumerator.each do |item|
          yield item
          @count += 1
          break if limit_check
        end

        last_page = page
      end
    end
def each
      last_page = nil
      until limit_check
        page = @block.call(last_page)
        return if page.empty?

        enumerator = if @direction == :down
                       page.each
                     elsif @direction == :up
                       page.reverse_each
                     end

        enumerator.each do |item|
          yield item
          @count += 1
          break if limit_check
        end

        last_page = page
      end
    end
Creates a new {Paginator}
 @param limit [Integer] the maximum number of items to request before stopping
 @param direction [:up, :down] the order in which results are returned in
 @yield [Array, nil] the last page of results, or nil if this is the first iteration.
   This should be used to request the next page of results.
 @yieldreturn [Array] the next page of results
 Yields every item produced by the wrapped request, until it returns
 no more results or the configured `limit` is reached.