diff options
author | Chris Schlaeger <chris@linux.com> | 2015-04-26 20:58:57 +0200 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2015-04-26 20:58:57 +0200 |
commit | 7494e2ec33a484c0bb8c9d8ca7b17cea8ed9c90c (patch) | |
tree | ff2e717fe63de0a44de5fc9f7119284de4e9f283 /lib | |
parent | 9e61a603ff582eae6140737727f7624751d668a8 (diff) | |
download | postrunner-7494e2ec33a484c0bb8c9d8ca7b17cea8ed9c90c.zip |
Use Activity.sport to select pace or speed.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/postrunner/Activity.rb | 2 | ||||
-rw-r--r-- | lib/postrunner/ActivitySummary.rb | 14 | ||||
-rw-r--r-- | lib/postrunner/ActivityView.rb | 2 |
3 files changed, 10 insertions, 8 deletions
diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb index 47390f5..3c92a5e 100644 --- a/lib/postrunner/Activity.rb +++ b/lib/postrunner/Activity.rb @@ -203,7 +203,7 @@ module PostRunner def summary @fit_activity = load_fit_file unless @fit_activity - puts ActivitySummary.new(@fit_activity, @db.cfg[:unit_system], + puts ActivitySummary.new(self, @db.cfg[:unit_system], { :name => @name, :type => activity_type, :sub_type => activity_sub_type }).to_s diff --git a/lib/postrunner/ActivitySummary.rb b/lib/postrunner/ActivitySummary.rb index ffb0901..159a642 100644 --- a/lib/postrunner/ActivitySummary.rb +++ b/lib/postrunner/ActivitySummary.rb @@ -21,8 +21,9 @@ module PostRunner include Fit4Ruby::Converters - def initialize(fit_activity, unit_system, custom_fields) - @fit_activity = fit_activity + def initialize(activity, unit_system, custom_fields) + @activity = activity + @fit_activity = activity.fit_activity @name = custom_fields[:name] @type = custom_fields[:type] @sub_type = custom_fields[:sub_type] @@ -54,9 +55,10 @@ module PostRunner local_value(session, 'total_distance', '%.2f %s', { :metric => 'km', :statute => 'mi'}) ]) t.row([ 'Time:', secsToHMS(session.total_timer_time) ]) - if session.sport == 'running' + if @activity.sport == 'running' || @activity.sport == 'multisport' t.row([ 'Avg. Pace:', pace(session, 'avg_speed') ]) - else + end + if @activity.sport != 'running' t.row([ 'Avg. Speed:', local_value(session, 'avg_speed', '%.1f %s', { :metric => 'km/h', :statute => 'mph' }) ]) @@ -100,7 +102,7 @@ module PostRunner t = FlexiTable.new t.head t.row([ 'Lap', 'Duration', 'Distance', - session.sport == 'running' ? 'Avg. Pace' : 'Avg. Speed', + @activity.sport == 'running' ? 'Avg. Pace' : 'Avg. Speed', 'Stride', 'Cadence', 'Avg. HR', 'Max. HR' ]) t.set_column_attributes(Array.new(8, { :halign => :right })) t.body @@ -109,7 +111,7 @@ module PostRunner t.cell(secsToHMS(lap.total_timer_time)) t.cell(local_value(lap, 'total_distance', '%.2f', { :metric => 'km', :statute => 'mi' })) - if session.sport == 'running' + if @activity.sport == 'running' t.cell(pace(lap, 'avg_speed', false)) else t.cell(local_value(lap, 'avg_speed', '%.1f', diff --git a/lib/postrunner/ActivityView.rb b/lib/postrunner/ActivityView.rb index bba1ec7..b36c5c2 100644 --- a/lib/postrunner/ActivityView.rb +++ b/lib/postrunner/ActivityView.rb @@ -61,7 +61,7 @@ module PostRunner # The main area with the 2 column layout. doc.div({ :class => 'main' }) { doc.div({ :class => 'left_col' }) { - ActivitySummary.new(@activity.fit_activity, @unit_system, + ActivitySummary.new(@activity, @unit_system, { :name => @activity.name, :type => @activity.activity_type, :sub_type => @activity.activity_sub_type |