Class: PostRunner::PersonalRecords::Record

Inherits:
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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(activity, sport, distance, duration, start_time) ⇒ Record

Returns a new instance of Record.



89
90
91
92
93
94
95
# File 'lib/postrunner/PersonalRecords.rb', line 89

def initialize(activity, sport, distance, duration, start_time)
  @activity = activity
  @sport = sport
  @distance = distance
  @duration = duration
  @start_time = start_time
end

Instance Attribute Details

#activityObject

Returns the value of attribute activity.



87
88
89
# File 'lib/postrunner/PersonalRecords.rb', line 87

def activity
  @activity
end

#distanceObject

Returns the value of attribute distance.



87
88
89
# File 'lib/postrunner/PersonalRecords.rb', line 87

def distance
  @distance
end

#durationObject

Returns the value of attribute duration.



87
88
89
# File 'lib/postrunner/PersonalRecords.rb', line 87

def duration
  @duration
end

#sportObject

Returns the value of attribute sport.



87
88
89
# File 'lib/postrunner/PersonalRecords.rb', line 87

def sport
  @sport
end

#start_timeObject

Returns the value of attribute start_time.



87
88
89
# File 'lib/postrunner/PersonalRecords.rb', line 87

def start_time
  @start_time
end

Instance Method Details

#to_table_row(t) ⇒ Object



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

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) ]) +
  [ @activity.db.ref_by_fit_file(@activity.fit_file),
    ActivityLink.new(@activity, false),
    @start_time.strftime("%Y-%m-%d") ])
end