File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -56,11 +56,13 @@ defmodule Display do
5656 end
5757
5858 defp format ( failure , module , name ) do
59+ progress_bar = ProgressBar . progress_bar ( Tracker . summarize ( ) )
60+ progress_bar_underline = String . duplicate ( "-" , String . length ( progress_bar ) )
5961 """
6062 #{ Intro . intro ( module , Tracker . visited ( ) ) }
6163 Now meditate upon #{ format_module ( module ) }
62- #{ ProgressBar . progress_bar ( Tracker . summarize ( ) ) }
63- ----------------------------------------
64+ #{ progress_bar }
65+ #{ progress_bar_underline }
6466 #{ name }
6567 #{ Failure . format_failure ( failure ) }
6668 """
Original file line number Diff line number Diff line change @@ -4,14 +4,19 @@ defmodule Display.ProgressBar do
44
55 def progress_bar ( % { current: current , total: total } ) do
66 arrow = calculate_progress ( current , total ) |> build_arrow
7+ progress_percentage = calculate_percentage ( current , total )
78
8- "|" <> String . pad_trailing ( arrow , @ progress_bar_length ) <> "| #{ current } of #{ total } "
9+ "|" <> String . pad_trailing ( arrow , @ progress_bar_length ) <> "| #{ current } of #{ total } -> #{ progress_percentage } % complete "
910 end
1011
1112 defp calculate_progress ( current , total ) do
1213 round ( current / total * @ progress_bar_length )
1314 end
1415
16+ defp calculate_percentage ( current , total ) do
17+ Float . round ( current / total * 100 , 1 )
18+ end
19+
1520 defp build_arrow ( 0 ) , do: ""
1621
1722 defp build_arrow ( length ) do
You can’t perform that action at this time.
0 commit comments