Class: Gooby::Run
Overview
Instances of this class represent a <Run> aggregate object from a
Forerunner XML file.
Additionally, there is distance, pace, and Google Map generation logic
in this class.
Instance Attribute Summary collapse
Instance Method Summary
collapse
#character_align, #default_delimiter, #invalid_altitude, #invalid_heartbeat, #invalid_latitude, #invalid_longitude, #invalid_time, #project_author, #project_copyright, #project_date, #project_embedded_comment, #project_license, #project_name, #project_version_number, #project_year, #read_as_ascii_lines, #read_lines, #strip_lines, #tokenize
Constructor Details
#initialize(number = 0, descr = '') ⇒ Run
Returns a new instance of Run.
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/gooby_run.rb', line 23
def initialize(number=0, descr='')
@number = number
@run_id = nil
@descr = descr
@notes = ''
@tracks = Array.new
@tkpts = Array.new
@laps = Array.new
@distance = 0
@configuration = Hash.new
@logProgress = true
@finished = false
end
|
Instance Attribute Details
#descr ⇒ Object
Returns the value of attribute descr.
21
22
23
|
# File 'lib/gooby_run.rb', line 21
def descr
@descr
end
|
#distance ⇒ Object
Returns the value of attribute distance.
21
22
23
|
# File 'lib/gooby_run.rb', line 21
def distance
@distance
end
|
#laps ⇒ Object
Returns the value of attribute laps.
21
22
23
|
# File 'lib/gooby_run.rb', line 21
def laps
@laps
end
|
#notes ⇒ Object
Returns the value of attribute notes.
21
22
23
|
# File 'lib/gooby_run.rb', line 21
def notes
@notes
end
|
#number ⇒ Object
Returns the value of attribute number.
21
22
23
|
# File 'lib/gooby_run.rb', line 21
def number
@number
end
|
#run_id ⇒ Object
Returns the value of attribute run_id.
21
22
23
|
# File 'lib/gooby_run.rb', line 21
def run_id
@run_id
end
|
#tkpts ⇒ Object
Returns the value of attribute tkpts.
21
22
23
|
# File 'lib/gooby_run.rb', line 21
def tkpts
@tkpts
end
|
#tracks ⇒ Object
Returns the value of attribute tracks.
21
22
23
|
# File 'lib/gooby_run.rb', line 21
def tracks
@tracks
end
|
Instance Method Details
#add_lap(lap) ⇒ Object
68
69
70
|
# File 'lib/gooby_run.rb', line 68
def add_lap(lap)
@laps.push(lap)
end
|
#add_track(trk) ⇒ Object
58
59
60
61
62
|
# File 'lib/gooby_run.rb', line 58
def add_track(trk)
if trk != nil
@tracks.push(trk)
end
end
|
#duration ⇒ Object
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/gooby_run.rb', line 96
def duration()
first = start_dttm()
last = end_dttm()
if first
if last
return last.hhmmss_diff(first)
end
end
return "00:00:00"
end
|
#end_dttm ⇒ Object
86
87
88
89
90
91
92
93
94
|
# File 'lib/gooby_run.rb', line 86
def end_dttm()
lastOne = nil
@tracks.each { |trk|
trk.trackpoints().each { |tkpt|
lastOne = tkpt.dttm()
}
}
lastOne
end
|
#end_hh_mm_ss ⇒ Object
123
124
125
126
127
128
129
|
# File 'lib/gooby_run.rb', line 123
def end_hh_mm_ss
if end_dttm()
end_dttm().hh_mm_ss()
else
""
end
end
|
#finish ⇒ Object
This method is invoked at end-of-parsing.
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/gooby_run.rb', line 40
def finish()
@logProgress = false
unless @finished
@tracks.each { |trk|
trk.trackpoints().each { |tkpt|
tkpt.run_number = @number
@tkpts.push(tkpt)
}
}
compute_distance_and_pace
compute_splits
set_run_ids
@finished = true
end
end
|
#lap_count ⇒ Object
72
73
74
|
# File 'lib/gooby_run.rb', line 72
def lap_count()
@laps.size
end
|
#print_string ⇒ Object
139
140
141
142
|
# File 'lib/gooby_run.rb', line 139
def print_string
finish() unless @finished
"Run number=#{@number} tracks=#{@tracks.size} tkpts=#{@tkpts.size} laps=#{@laps.size} distance=#{@distance} "
end
|
#put_csv ⇒ Object
144
145
146
147
|
# File 'lib/gooby_run.rb', line 144
def put_csv()
finish() unless @finished
puts "#{@number}|#{}|#{start_yyyy_mm_dd()}|#{start_hh_mm_ss()}|#{end_hh_mm_ss}|#{duration()}|#{@distance}|#{@tracks.size}|#{trackpoint_count()}|#{lap_count}|#{@notes.strip}"
end
|
#put_laps ⇒ Object
157
158
159
|
# File 'lib/gooby_run.rb', line 157
def put_laps
@laps.each { | lap | puts lap.to_s }
end
|
#put_tkpt_csv ⇒ Object
149
150
151
152
153
154
155
|
# File 'lib/gooby_run.rb', line 149
def put_tkpt_csv()
finish() unless @finished
@tkpts.each { | tkpt |
@prev_tkpt = tkpt if (@prev_tkpt == nil)
puts tkpt.to_csv(@prev_tkpt)
}
end
|
#start_dttm ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/gooby_run.rb', line 76
def start_dttm()
count = 0
@tracks.each { |trk|
trk.trackpoints().each { |tkpt|
return tkpt.dttm()
}
}
return nil
end
|
#start_hh_mm_ss ⇒ Object
115
116
117
118
119
120
121
|
# File 'lib/gooby_run.rb', line 115
def start_hh_mm_ss
if start_dttm()
start_dttm().hh_mm_ss()
else
""
end
end
|
#start_yyyy_mm_dd ⇒ Object
107
108
109
110
111
112
113
|
# File 'lib/gooby_run.rb', line 107
def start_yyyy_mm_dd
if start_dttm()
start_dttm().yyyy_mm_dd()
else
""
end
end
|
#to_s ⇒ Object
131
132
133
134
135
136
137
|
# File 'lib/gooby_run.rb', line 131
def to_s
finish() unless @finished
s = "Run: #{@number} date: #{start_yyyy_mm_dd} distance: #{distance} duration: #{duration} "
s << " tracks: #{@tracks.size} tkpts: #{trackpoint_count} laps: #{lap_count} "
s << " notes: #{@notes} "
s
end
|
#trackpoint_count ⇒ Object
64
65
66
|
# File 'lib/gooby_run.rb', line 64
def trackpoint_count()
@tkpts.size()
end
|