Class: Strava::Route

Inherits:
Base
  • Object
show all
Defined in:
lib/strava/route.rb

Instance Attribute Summary

Attributes inherited from Base

#client, #id, #response

Instance Method Summary collapse

Methods inherited from Base

#detailed?, #initialize, #resource_state, resource_states, #summary?

Constructor Details

This class inherits a constructor from Strava::Base

Instance Method Details

#get_detailsObject



22
23
24
25
26
27
# File 'lib/strava/route.rb', line 22

def get_details
  return self if detailed?
  res = client.get(path_base).to_h
  update(res)
  res
end

#get_streams(**params) ⇒ Object



29
30
31
32
# File 'lib/strava/route.rb', line 29

def get_streams(**params)
  res = client.get(path_streams, **params).to_a
  @streams.update(res)
end

#path_baseObject



34
35
36
# File 'lib/strava/route.rb', line 34

def path_base
  "routes/#{id}"
end

#path_streamsObject



38
39
40
# File 'lib/strava/route.rb', line 38

def path_streams
  "#{path_base}/streams/"
end

#set_ivarsObject

Class to represent Strava Activity https://strava.github.io/api/v3/activities/



6
7
8
# File 'lib/strava/route.rb', line 6

def set_ivars
  @streams = StreamSet.new
end

#streams(**params) ⇒ Object



17
18
19
20
# File 'lib/strava/route.rb', line 17

def streams(**params)
  get_streams(**params) if @streams.empty?
  @streams
end

#update(data, **opts) ⇒ Object



10
11
12
13
14
15
# File 'lib/strava/route.rb', line 10

def update(data, **opts)
  @response = data
  @id                     = data["id"]
  @resource_state         = data['resource_state']
  self
end