locknet.ro

archive

Procrastination of the Day

str = File.read("time_tracker.textile")
minutes = 0
m = str.scan /^\* ([0-9]{1}):([0-9]{2}) -/i
while m.size > 0 do
  h, min = m.shift
  minutes += min.to_i+(h.to_i*60)
end
puts "--> Total Time: #{minutes/60}:#{minutes%60}"

Because scan is nice.