Class: Strava::RunningRace
- Inherits:
-
Base
- Object
- Base
- Strava::RunningRace
show all
- Defined in:
- lib/strava/running_race.rb
Instance Attribute Summary
Attributes inherited from Base
#client, #id, #response
Class Method Summary
collapse
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
Class Method Details
.list_races(client, year = Time.now.year) ⇒ Object
36
37
38
39
|
# File 'lib/strava/running_race.rb', line 36
def self.list_races(client, year = Time.now.year)
res = client.get("running_races", year: year).to_a
res.map { |hash| new(hash, client: client) }
end
|
Instance Method Details
#get_details ⇒ Object
26
27
28
29
30
31
|
# File 'lib/strava/running_race.rb', line 26
def get_details
return self if detailed?
res = client.get(path_base).to_h
update(res)
res
end
|
#path_base ⇒ Object
32
33
34
|
# File 'lib/strava/running_race.rb', line 32
def path_base
"running_races/#{id}"
end
|
#update(data, **opts) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/strava/running_race.rb', line 4
def update(data, **opts)
@response = data
@id = data['id']
@resource_state = data['resource_state']
@name = data["name"]
@start_date_local = data["start_date_local"]
@distance = data["distance"]
@city = data["city"]
@state = data["state"]
@country = data["country"]
@measurement_preference = data["measurement_preference"]
@running_race_type = data["running_race_type"]
@url = data["url"]
@resource_state = data["resource_state"]
@status = data["status"]
@website_url = data["website_url"]
@route_ids = data["route_ids"]
self
end
|