Commit 673f3c34 authored by Thomas R. Koll's avatar Thomas R. Koll

Without any arguments display the average over the last week

parent 2c472f69
......@@ -2,13 +2,20 @@
require 'pp'
require 'chronic'
require 'csv'
require 'date'
DEBUG = false
moodfile = "#{ENV['HOME']}/.mood"
if ARGV.empty?
system("tail #{moodfile}")
csv =
last_week = - 6
pp csv
moods ={|d| d[0] && DateTime.parse(d[0]) > last_week }.collect{|d| d[1].to_i }
avg = moods.sum / moods.count.to_f
puts "Your mood in the last week was #{avg.round} with #{moods.count} entries"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment