Module: Strava::Models::Mixins::SportType
- Extended by:
- ActiveSupport::Concern
- Included in:
- DetailedActivity, SummaryActivity
- Defined in:
- lib/strava/models/mixins/sport_type.rb
Overview
Provides sport type handling and sport-specific formatting.
This mixin adds the sport_type property and provides sport-aware formatting for distance and pace. For example, swimming activities display distance in meters and pace per 100m, while other activities use kilometers and pace per km.
Also provides emoji representations for various sport types.
Instance Method Summary collapse
-
#distance_s ⇒ String?
Returns distance formatted appropriately for the sport type.
-
#pace_s ⇒ String?
Returns pace formatted appropriately for the sport type.
-
#sport_type_emoji ⇒ String?
Returns an emoji representing the sport type.
Instance Method Details
#distance_s ⇒ String?
Returns distance formatted appropriately for the sport type.
Swimming activities display distance in meters, while all other activities use kilometers.
39 40 41 42 43 44 45 |
# File 'lib/strava/models/mixins/sport_type.rb', line 39 def distance_s if sport_type == 'Swim' distance_in_meters_s else distance_in_kilometers_s end end |
#pace_s ⇒ String?
Returns pace formatted appropriately for the sport type.
Swimming activities display pace per 100 meters, while all other activities use pace per kilometer.
55 56 57 58 59 60 61 62 |
# File 'lib/strava/models/mixins/sport_type.rb', line 55 def pace_s case sport_type when 'Swim' pace_per_100_meters_s else pace_per_kilometer_s end end |
#sport_type_emoji ⇒ String?
Returns an emoji representing the sport type.
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 |
# File 'lib/strava/models/mixins/sport_type.rb', line 69 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 |