lib/strava/models/mixins/elevation.rb in strava-ruby-client-0.3.0 vs lib/strava/models/mixins/elevation.rb in strava-ruby-client-0.3.1

- old
+ new

@@ -7,39 +7,30 @@ included do property 'total_elevation_gain' end def total_elevation_gain_in_feet - case units - when :metric then total_elevation_gain * 3.28084 - when :imperial then total_elevation_gain - end + total_elevation_gain * 3.28084 end def total_elevation_gain_in_meters - case units - when :metric then total_elevation_gain - when :imperial then total_elevation_gain / 3.28084 - end + total_elevation_gain end def total_elevation_gain_in_meters_s - return unless total_elevation_gain && total_elevation_gain.positive? + return if total_elevation_gain.nil? format('%gm', format('%.1f', total_elevation_gain_in_meters)) end def total_elevation_gain_in_feet_s - return unless total_elevation_gain && total_elevation_gain.positive? + return if total_elevation_gain.nil? format('%gft', format('%.1f', total_elevation_gain_in_feet)) end def total_elevation_gain_s - case units - when :metric then total_elevation_gain_in_meters_s - when :imperial then total_elevation_gain_in_feet_s - end + total_elevation_gain_in_meters_s end end end end end