From 85217081ba9817e67f3a8cc2ad5afcb5e027bf27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20M=C3=BCller=20Madsen?= Date: Mon, 8 May 2017 23:14:37 +0200 Subject: [PATCH] change code style in stats.erb to make @Jmaa and @ohayo-jacob happy --- stats.erb | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/stats.erb b/stats.erb index 892ef08..e300463 100644 --- a/stats.erb +++ b/stats.erb @@ -19,32 +19,40 @@ <% require 'filesize' class User - include Comparable - attr_accessor :name,:count,:size + attr_accessor :name, :count, :size def <=> (other) other.count <=> count end end usernames = ["christoffermadsen","jmaa","jacob","alexander"] - users = [] - shot_dir = "/var/shots/" + users = [] + shot_dir = "/var/shots/" usernames.each do |username| - user = User.new + user = User.new user.name = username - size = `du -B1 #{shot_dir}#{username}/ | awk {'print $1'} | head -n 1` - count = `ls -1 #{shot_dir}#{username}/ | wc -l | head -n 1` + size = `du -B1 #{shot_dir}#{username}/ | awk {'print $1'} | head -n 1` + count = `ls -1 #{shot_dir}#{username}/ | wc -l | head -n 1` + [size,count].each do |x| x.delete! "\n" end - user.size = size.to_i + + user.size = size.to_i user.count = count.to_i - users << user + users << user end count = 0 users.sort.each do |user| count += 1 - %> - <%= "#{count}#{user.name}#{user.count}#{Filesize.from(user.size.to_s + "B").pretty}" %> + %> + <%= %Q{ + + #{count} + #{user.name} + #{user.count} + #{Filesize.from(user.size.to_s + "B").pretty} + } + %> <% end %>

Charts