Created
November 8, 2012 05:14
-
-
Save saterus/4036949 to your computer and use it in GitHub Desktop.
Sums Files
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
dir = ARGV.shift.strip | |
sum = 0 | |
Dir.glob(dir + "/*.txt").each do |file| | |
vals = IO.read(file).scan(/\(([0-9]+)\//).flatten.map(&:to_i) | |
puts "Values extracted: ", vals | |
s = vals.inject(:+) | |
puts "File Sum: #{s}" | |
sum += s | |
puts "Total Sum: #{sum}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment