lib/strava/models/activity.rb in strava-ruby-client-0.1.0 vs lib/strava/models/activity.rb in strava-ruby-client-0.2.0
- old
+ new
@@ -1,16 +1,17 @@
module Strava
module Models
class Activity < Model
+ include Mixins::Distance
+ include Mixins::Time
+ include Mixins::Elevation
+
property 'id'
property 'resource_state'
property 'athlete', transform_with: ->(v) { Strava::Models::Athlete.new(v) }
property 'name'
- property 'distance'
- property 'moving_time'
- property 'elapsed_time'
- property 'total_elevation_gain'
+ property 'description'
property 'type'
property 'workout_type'
property 'id'
property 'external_id'
property 'upload_id'
@@ -50,8 +51,93 @@
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::Metric.new(r) } }
+ property 'splits_standard', transform_with: ->(v) { v.map { |r| Strava::Models::Split::Standard.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'
+
+ def units
+ :metric
+ end
+
+ def distance_s
+ if type == 'Swim'
+ case units
+ when :metric then distance_in_meters_s
+ when :imperial then distance_in_yards_s
+ end
+ else
+ case units
+ when :metric then distance_in_kilometers_s
+ when :imperial then distance_in_miles_s
+ end
+ end
+ end
+
+ def pace_s
+ case type
+ when 'Swim'
+ case units
+ when :metric then pace_per_100_meters_s
+ when :imperial then pace_per_100_yards_s
+ end
+ else
+ case units
+ when :metric then pace_per_kilometer_s
+ when :imperial then pace_per_mile_s
+ end
+ end
+ end
+
+ def strava_url
+ "https://www.strava.com/activities/#{id}"
+ end
+
+ def type_emoji
+ case type
+ when 'Run' then 'π'
+ when 'Ride' then 'π΄'
+ when 'Swim' then 'π'
+ when 'Walk' then 'πΆ'
+ when 'AlpineSki' then 'β·οΈ'
+ when 'BackcountrySki' then 'πΏοΈ'
+ # when 'Canoeing' then ''
+ # when 'Crossfit' then ''
+ when 'EBikeRide' 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 'VirtualRide' then 'π΄'
+ when 'VirtualRun' then 'π'
+ when 'WeightTraining' then 'ποΈ'
+ # when 'Windsurf' then ''
+ when 'Wheelchair' then 'βΏ'
+ # when 'Workout' then ''
+ # when 'Yoga'' then ''
+ end
+ end
end
end
end