Class: TCXReader::Lap

Inherits:
Object
  • Object
show all
Defined in:
lib/tcx_reader/lap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lap) ⇒ Lap

Returns a new instance of Lap.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tcx_reader/lap.rb', line 27

def initialize(lap)
  @start_time     = Time.parse(lap["StartTime"])
  @time_seconds   = lap.at_css("TotalTimeSeconds").text.to_f rescue nil
  @distance_meter = lap.at_css("DistanceMeters").text.to_f rescue nil
  @max_speed      = lap.at_css("MaximumSpeed").text.to_f rescue nil
  @calories       = lap.at_css("Calories").text.to_i rescue nil
  @avg_hr         = lap.at_css("AverageHeartRateBpm Value").text.to_i rescue nil
  @max_hr         = lap.at_css("MaximumHeartRateBpm Value").text.to_i rescue nil
  @intensity      = lap.at_css("Intensity").text rescue nil
  @trigger_method = lap.at_css("TriggerMethod").text rescue nil
  @tracks = []
  lap.css("Track").each do |trk|
    trk     = Track.new(trk)
    @tracks << trk
  end
end

Instance Attribute Details

#avg_hrObject

Returns the value of attribute avg_hr.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def avg_hr
  @avg_hr
end

#caloriesObject

Returns the value of attribute calories.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def calories
  @calories
end

#distance_meterObject

Returns the value of attribute distance_meter.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def distance_meter
  @distance_meter
end

#intensityObject

Returns the value of attribute intensity.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def intensity
  @intensity
end

#max_hrObject

Returns the value of attribute max_hr.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def max_hr
  @max_hr
end

#max_speedObject

Returns the value of attribute max_speed.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def max_speed
  @max_speed
end

#start_timeObject

Returns the value of attribute start_time.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def start_time
  @start_time
end

#time_secondsObject

Returns the value of attribute time_seconds.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def time_seconds
  @time_seconds
end

#tracksObject

Returns the value of attribute tracks.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def tracks
  @tracks
end

#trigger_methodObject

Returns the value of attribute trigger_method.



25
26
27
# File 'lib/tcx_reader/lap.rb', line 25

def trigger_method
  @trigger_method
end