Last active
July 19, 2016 12:59
-
-
Save romuloceccon/b2b1cb41fbe0a9767606de51d43eda2c to your computer and use it in GitHub Desktop.
Convert Hal Higdon training plans from miles to km (http://halhigdon.com/training/51135/Marathon-Training-Guide/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'csv' | |
| CSV do |out| | |
| csv = CSV.new(STDIN) | |
| csv.each do |row| | |
| out << row.map do |x| | |
| if m = x.match(/^\d+$/) | |
| (m[0].to_i * 1.6).round.to_s | |
| elsif m = x.match(/^(\d+)( m)(.*)$/) | |
| (m[1].to_i * 1.6).round.to_s + ' km' + m[3] | |
| else | |
| x | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment