9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/bars.rb', line 9
def print(options={})
line_width = options.delete(:line_width) { 25 } - 1
puts
@timeframes.each do |timeframe, tasks|
tasks.each do |task, done, goal|
percent = (done.to_f/goal)
count = (percent * line_width.to_f).round
done_string = "█" * (count)
todo_string = "┅" * (line_width - count)
percent_string = sprintf("%.1f%", (percent * 100)).rjust(6)
goal_string = "#{done}/#{goal}".rjust(7)
puts "#{task.ljust(line_width - 7)}#{goal_string}"
puts "#{done_string}#{todo_string}#{percent_string}"
end
puts
end
end
|