forked from dblock/strava-ruby-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivity.rb
182 lines (175 loc) · 6 KB
/
activity.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# frozen_string_literal: true
module Strava
module Models
class Activity < Strava::Models::Response
include Mixins::Time
include Mixins::Distance
include Mixins::Elevation
include Mixins::StartDateLocal
property 'id'
property 'resource_state'
property 'athlete', transform_with: ->(v) { Strava::Models::Athlete.new(v) }
property 'name'
property 'description'
property 'type' # deprecated
property 'sport_type'
property 'workout_type'
property 'id'
property 'external_id'
property 'upload_id'
property 'start_date', transform_with: ->(v) { Time.parse(v) }
property 'timezone'
property 'utc_offset'
property 'start_latlng'
property 'end_latlng'
property 'location_city'
property 'location_state'
property 'location_country'
property 'start_latitude'
property 'start_longitude'
property 'achievement_count'
property 'kudos_count'
property 'comment_count'
property 'athlete_count'
property 'photo_count'
property 'map', transform_with: ->(v) { Strava::Models::Map.new(v) }
property 'trainer'
property 'commute'
property 'manual'
property 'private'
property 'visibility'
property 'flagged'
property 'gear_id'
property 'from_accepted_tag'
property 'average_speed'
property 'max_speed'
property 'has_heartrate'
property 'average_heartrate'
property 'max_heartrate'
property 'heartrate_opt_out'
property 'display_hide_heartrate_option'
property 'elev_high'
property 'elev_low'
property 'pr_count'
property 'total_photo_count'
property 'has_kudoed'
property 'suffer_score'
property 'calories'
property 'segment_efforts', transform_with: ->(v) { v.map { |r| Strava::Models::SegmentEffort.new(r) } }
property 'best_efforts', transform_with: ->(v) { v.map { |r| Strava::Models::SegmentEffort.new(r) } }
property 'photos', transform_with: ->(v) { Strava::Models::Photos.new(v) }
property 'similar_activities', transform_with: ->(v) { Strava::Models::SimilarActivities.new(v) }
property 'embed_token'
property 'available_zones'
property 'splits_metric', transform_with: ->(v) { v.map { |r| Strava::Models::Split.new(r) } }
property 'splits_standard', transform_with: ->(v) { v.map { |r| Strava::Models::Split.new(r) } }
property 'laps', transform_with: ->(v) { v.map { |r| Strava::Models::Lap.new(r) } }
property 'gear', transform_with: ->(v) { Strava::Models::Gear.new(v) }
property 'device_name'
property 'average_cadence'
property 'average_temp'
property 'average_watts'
property 'weighted_average_watts'
property 'kilojoules'
property 'device_watts'
property 'max_watts'
property 'highlighted_kudosers', transform_with: ->(v) { v.map { |r| Strava::Models::Kudoser.new(r) } }
property 'segment_leaderboard_opt_out'
property 'leaderboard_opt_out'
def distance_s
if type == 'Swim'
distance_in_meters_s
else
distance_in_kilometers_s
end
end
def pace_s
case type
when 'Swim'
pace_per_100_meters_s
else
pace_per_kilometer_s
end
end
def strava_url
"https://www.strava.com/activities/#{id}"
end
def sport_type_emoji
case sport_type
when 'AlpineSki' then '⛷️'
when 'BackcountrySki' then '🎿️'
# when "Canoeing" then ''
# when "Crossfit" then ''
# when "Elliptical" then ''
when 'Golf' then '🏌️'
# when "Handcycle" then ''
when 'Hike' then '🥾'
when 'IceSkate' then '⛸'
when 'InlineSkate' then "\u{1F6FC}"
# when "Kayaking" then ''
# when "Kitesurf" then ''
when 'MountainBikeRide', 'EMountainBikeRide' then '🚵'
# when "NordicSki" then ''
when 'Ride', 'EBikeRide', 'VirtualRide', 'GravelRide' then '🚴'
when 'RockClimbing' then '🧗'
# when 'RollerSki' then ''
when 'Rowing' then '🚣'
when 'Run', 'VirtualRun', 'TrailRun' then '🏃'
when 'Sail' then '⛵️'
when 'Skateboard' then '🛹'
when 'Snowboard' then '🏂'
# when 'Snowshoe' then ''
when 'Soccer' then '⚽️'
# when 'StairStepper' then ''
# when 'StandUpPaddling' then ''
when 'Surfing' then '🏄'
when 'Swim' then '🏊'
# when 'Velomobile' then ''
when 'Walk' then '🚶'
when 'WeightTraining' then '🏋️'
when 'Wheelchair' then '♿'
# when 'Windsurf' then ''
# when 'Workout' then ''
when 'Yoga' then '🧘'
end
end
#
# @deprecated Use {#sport_type_emoji} instead.
#
# @return [String] precisely an emoji
#
def type_emoji
case type
when 'Run', 'VirtualRun' then '🏃'
when 'Ride', 'EBikeRide', 'VirtualRide' then '🚴'
when 'Swim' then '🏊'
when 'Walk' then '🚶'
when 'AlpineSki' then '⛷️'
when 'BackcountrySki' then '🎿️'
# when 'Canoeing' then ''
# when 'Crossfit' then ''
# when 'Elliptical' then ''
# when 'Hike' then ''
when 'IceSkate' then '⛸️'
# when 'InlineSkate' then ''
# when 'Kayaking' then ''
# when 'Kitesurf' then ''
# when 'NordicSki' then ''
when 'RockClimbing' then '🧗'
when 'RollerSki' then ''
when 'Rowing' then '🚣'
when 'Snowboard' then '🏂'
# when 'Snowshoe' then ''
# when 'StairStepper' then ''
# when 'StandUpPaddling' then ''
when 'Surfing' then '🏄'
when 'WeightTraining' then '🏋️'
# when 'Windsurf' then ''
when 'Wheelchair' then '♿'
# when 'Workout' then ''
# when 'Yoga'' then ''
end
end
end
end
end