Module: StravaApi::Segments

Included in:
Base
Defined in:
lib/strava-api/segments.rb

Instance Method Summary collapse

Instance Method Details

#segment_efforts(id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/strava-api/segments.rb', line 16

def segment_efforts(id, options = {})
  options_map = {
    :club_id => 'clubId',
    :athlete_id => 'athleteId',
    :athlete_name => 'athleteName',
    :start_date => 'startDate',
    :end_date => 'endDate',
    :start_id => 'startId',
    :best => 'best',
    :offset => 'offset'
  }
  
  #convert between rails format names and camel case
  filtered_options = {}
  options_map.each_pair do |key, converted|
    filtered_options[converted] = options[key] if options[key]
  end

  result = call("segments/#{id}/efforts", "efforts", filtered_options)

  result["efforts"].collect {|effort| Effort.new(self, effort)}
end

#segment_show(id) ⇒ Object



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

def segment_show(id)
  result = call("segments/#{id}", "segment", {})

  Segment.new(self, result["segment"])
end

#segments(name) ⇒ Object

returns all segments, don’t need an offset



4
5
6
7
8
# File 'lib/strava-api/segments.rb', line 4

def segments(name)
  result = call("segments", "segments", {:name => name})

  result["segments"].collect {|item| Segment.new(self, item)}
end