Sha256: 11a6e5918cecc58e40ef8d25bde440dd9a7e2aa1d49345ec6535607350d93f07

Contents?: true

Size: 551 Bytes

Versions: 7

Compression:

Stored size: 551 Bytes

Contents

module Strava
  module Api
    class Cursor
      include Enumerable

      attr_reader :client
      attr_reader :path
      attr_reader :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-0.4.2 lib/strava/api/cursor.rb
strava-ruby-client-0.4.1 lib/strava/api/cursor.rb
strava-ruby-client-0.4.0 lib/strava/api/cursor.rb
strava-ruby-client-0.3.2 lib/strava/api/cursor.rb
strava-ruby-client-0.3.1 lib/strava/api/cursor.rb
strava-ruby-client-0.3.0 lib/strava/api/cursor.rb
strava-ruby-client-0.2.0 lib/strava/api/cursor.rb