Class: Strava::Api::Cursor

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/strava/api/cursor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, path, params = {}) ⇒ Cursor

Returns a new instance of Cursor.



10
11
12
13
14
# File 'lib/strava/api/cursor.rb', line 10

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

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/strava/api/cursor.rb', line 8

def client
  @client
end

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/strava/api/cursor.rb', line 8

def params
  @params
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/strava/api/cursor.rb', line 8

def path
  @path
end

Instance Method Details

#eachObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/strava/api/cursor.rb', line 16

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