Class: Strava::Api::Cursor
- Inherits:
-
Object
- Object
- Strava::Api::Cursor
- Includes:
- Enumerable
- Defined in:
- lib/strava/api/cursor.rb
Overview
Handles paginated iteration through API endpoints.
This class provides an Enumerable interface for iterating through paginated API responses. It supports both traditional page-based pagination and cursor-based pagination.
Instance Attribute Summary collapse
-
#client ⇒ Strava::Api::Client
readonly
API client instance.
-
#params ⇒ Hash
readonly
Query parameters for the request.
-
#path ⇒ String
readonly
API endpoint path.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(client, path, params = {}) ⇒ Cursor
constructor
Initialize a new Cursor for paginated iteration.
Constructor Details
#initialize(client, path, params = {}) ⇒ Cursor
Initialize a new Cursor for paginated iteration.
41 42 43 44 45 |
# File 'lib/strava/api/cursor.rb', line 41 def initialize(client, path, params = {}) @client = client @path = path @params = params.key?(:limit) ? params.dup.tap { |p| p.delete :limit } : params end |
Instance Attribute Details
#client ⇒ Strava::Api::Client (readonly)
Returns API client instance.
26 27 28 |
# File 'lib/strava/api/cursor.rb', line 26 def client @client end |
#params ⇒ Hash (readonly)
Returns Query parameters for the request.
32 33 34 |
# File 'lib/strava/api/cursor.rb', line 32 def params @params end |
#path ⇒ String (readonly)
Returns API endpoint path.
29 30 31 |
# File 'lib/strava/api/cursor.rb', line 29 def path @path end |
Instance Method Details
#each(&block) ⇒ Object
47 48 49 |
# File 'lib/strava/api/cursor.rb', line 47 def each(&block) params[:page_size] ? each_cursor(&block) : each_page(&block) end |