Class: PostRunner::PersonalRecords::Record

Inherits:
PEROBS::Object
  • Object
show all
Includes:
Fit4Ruby::Converters
Defined in:
lib/postrunner/PersonalRecords.rb

Overview

The Record class stores a single speed or longest distance record. It also stores a reference to the Activity that contains the record.

Instance Method Summary collapse

Constructor Details

#initialize(p, result) ⇒ Record

Returns a new instance of Record.



99
100
101
102
103
104
105
106
107
# File 'lib/postrunner/PersonalRecords.rb', line 99

def initialize(p, result)
  super(p)

  self.activity = result.activity
  self.sport = result.sport
  self.distance = result.distance
  self.duration = result.duration
  self.start_time = result.start_time
end

Instance Method Details

#to_table_row(t) ⇒ Object



109
110
111
112
113
114
115
116
117
118
# File 'lib/postrunner/PersonalRecords.rb', line 109

def to_table_row(t)
  t.row((@duration.nil? ?
         [ 'Longest Distance', '%.3f km' % (@distance / 1000.0), '-' ] :
         [ PersonalRecords::SpeedRecordDistances[@sport][@distance],
           secsToHMS(@duration),
           speedToPace(@distance / @duration) ]) +
        [ @store['file_store'].ref_by_activity(@activity),
          ActivityLink.new(@activity, false),
          @start_time.strftime("%Y-%m-%d") ])
end