Sha256: b13079ca7eec88acf0c7e852e7c96467eb23d54dcfbf0a7d2eaf41d85d123141

Contents?: true

Size: 548 Bytes

Versions: 7

Compression:

Stored size: 548 Bytes

Contents

# frozen_string_literal: true

module Strava
  module Api
    class Cursor
      include Enumerable

      attr_reader :client, :path, :params

      def initialize(client, path, params = {})
        @client = client
        @path = path
        @params = params
      end

      def each
        next_page = 1
        loop do
          query = params.merge(page: next_page)
          response = client.get(path, query)
          break unless response.any?

          yield response
          next_page += 1
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
strava-ruby-client-2.2.0 lib/strava/api/cursor.rb
strava-ruby-client-2.1.0 lib/strava/api/cursor.rb
strava-ruby-client-2.0.0 lib/strava/api/cursor.rb
strava-ruby-client-1.1.0 lib/strava/api/cursor.rb
strava-ruby-client-1.0.1 lib/strava/api/cursor.rb
strava-ruby-client-1.0.0 lib/strava/api/cursor.rb
strava-ruby-client-0.4.3 lib/strava/api/cursor.rb