Skip to content

Instantly share code, notes, and snippets.

@CodisRedding
Created July 22, 2013 18:15
Show Gist options
  • Save CodisRedding/6056167 to your computer and use it in GitHub Desktop.
Save CodisRedding/6056167 to your computer and use it in GitHub Desktop.
require 'fileutils'
require_relative 'activity'
require_relative 'garmin_connector'
# Check for Garmin device
#connector = GarminConnector.new
#if !connector.garmin_connected?
# puts "No Garmin device found."
# exit
#end
# Pull directly from garmin 500 activites
puts "Converting .fit files to .tcx..."
#connector.convert_fit_to_tcx
puts "Completed conversions"
Dir.glob("tcx/*.tcx") do |f|
activity = Activity.new(f)
if activity.zones
puts "\nRide: #{activity.start_time}\n"
zone = 0
activity.zones.each do |z|
zone += 1
puts "Zone#{zone}\t Time in Zone: #{z.total_minutes}\t Percentage: #{z.percentage(activity.total_minutes)}"
end
end
if activity.watts
activity.watts.each do |w|
print "#{w.range} W ".rjust(10) + "\t"
print "Time Spent: " + "#{w.total_time}".ljust(9) + " (#{w.percentage(activity.total_minutes)}%)".ljust(9)
puts " |#{((w.percentage(activity.total_minutes)) * 50).round.times { |x| print '-' }}|"
end
end
# Remove tcx file.
#FileUtils.rm(f)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment