Skip to content

Instantly share code, notes, and snippets.

@jamesmartin
Last active August 16, 2016 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmartin/f43bb34eb6f56962c2d5c31fa3c301a5 to your computer and use it in GitHub Desktop.
Save jamesmartin/f43bb34eb6f56962c2d5c31fa3c301a5 to your computer and use it in GitHub Desktop.
# 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