Last active
August 16, 2016 00:00
-
-
Save jamesmartin/f43bb34eb6f56962c2d5c31fa3c301a5 to your computer and use it in GitHub Desktop.
This file contains 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
# Gives an accurate balance for 28degrees credit card including pending transactions. | |
# Copy pasta the transactions from the 28degrees website into a plain text | |
# file and then feed it into this script. | |
# | |
# $> ruby 28degrees.rb some-text-file.txt | |
# | |
if $0 == __FILE__ | |
unless ARGV[0] | |
puts "Usage: #{__FILE__} filename" | |
exit 1 | |
end | |
lines = File.readlines(ARGV[0]) | |
monies = lines.select { |l| /\$/.match(l) } | |
total = monies.reduce(0) { |t, m| t += m.gsub(/\$/, "").to_f; t } | |
puts total | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment