Module: Strava::Api::Endpoints::Segments
- Included in:
- Client
- Defined in:
- lib/strava/api/endpoints/segments.rb
Overview
API endpoints for Strava segments.
Segments are specific sections of road or trail where athletes can compete for time. This module provides methods for exploring, retrieving, and starring segments.
Instance Method Summary collapse
-
#explore_segments(options = {}) ⇒ Array<Strava::Models::ExplorerSegment>
Explore segments in a geographic area.
-
#segment(id_or_options, options = {}) ⇒ DetailedSegment
Returns the specified segment.
-
#star_segment(id_or_options, options = {}) ⇒ DetailedSegment
Stars/Unstars the given segment for the authenticated athlete.
-
#starred_segments(options = {}) {|SummarySegment| ... } ⇒ Array<SummarySegment>, Cursor
List of the authenticated athlete's starred segments.
Instance Method Details
#explore_segments(options = {}) ⇒ Array<Strava::Models::ExplorerSegment>
Explore segments in a geographic area.
Returns the top 10 segments matching a specified query within a rectangular geographic boundary. Useful for discovering popular segments in an area.
37 38 39 40 41 42 43 44 45 |
# File 'lib/strava/api/endpoints/segments.rb', line 37 def explore_segments( = {}) raise ArgumentError, 'Required argument :bounds missing' if [:bounds].nil? bounds = [:bounds] bounds = bounds.map(&:to_s).join(',') if bounds.is_a?(Array) get('segments/explore', .merge(bounds: bounds))['segments'].map do |row| Strava::Models::ExplorerSegment.new(row) end end |
#segment(id_or_options, options = {}) ⇒ DetailedSegment
Returns the specified segment.
Retrieves detailed information about a specific segment including location, elevation profile, and the athlete's personal records on that segment.
85 86 87 88 |
# File 'lib/strava/api/endpoints/segments.rb', line 85 def segment(, = {}) id, = parse_args(, ) Strava::Models::DetailedSegment.new(get("segments/#{id}", )) end |
#star_segment(id_or_options, options = {}) ⇒ DetailedSegment
Stars/Unstars the given segment for the authenticated athlete.
Adds or removes a segment from the athlete's starred/favorite segments. Starred segments appear in the athlete's starred segments list and can be used to track performance over time.
111 112 113 114 115 116 |
# File 'lib/strava/api/endpoints/segments.rb', line 111 def star_segment(, = {}) id, = parse_args(, ) raise ArgumentError, 'Required argument :starred missing' if [:starred].nil? Strava::Models::DetailedSegment.new(put("segments/#{id}/starred", )) end |
#starred_segments(options = {}) {|SummarySegment| ... } ⇒ Array<SummarySegment>, Cursor
List of the authenticated athlete's starred segments.
Returns a paginated list of segments that the authenticated athlete has starred. Starred segments are favorites that the athlete wants to track their performance on.
66 67 68 |
# File 'lib/strava/api/endpoints/segments.rb', line 66 def starred_segments( = {}, &block) paginate 'segments/starred', , Strava::Models::SummarySegment, &block end |