Class: Strava::Api::Cursor
- Inherits:
-
Object
- Object
- Strava::Api::Cursor
- Includes:
- Enumerable
- Defined in:
- lib/strava/api/cursor.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(client, path, params = {}) ⇒ Cursor
constructor
A new instance of Cursor.
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
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/strava/api/cursor.rb', line 8 def client @client end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/strava/api/cursor.rb', line 8 def params @params end |
#path ⇒ Object (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
#each ⇒ Object
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 |