lib/progressbar.rb in narou-2.9.5 vs lib/progressbar.rb in narou-3.0.0

- old
+ new

@@ -13,11 +13,11 @@ @char = char @counter = 0 end def output(num) - return if $debug + return if silence? if num > @max raise OverRangeError, "`#{num}` over `#{@max}(max)`" end @counter += 1 return unless @counter % @interval == 0 @@ -26,13 +26,17 @@ rest = @width - now STDOUT.print "[" + @char * now + ' ' * rest + "] #{(ratio * 100).round}%\r" end def clear - return if $debug + return if silence? STDOUT.print " " * 79 + "\r" end def calc_ratio(num) num / @max + end + + def silence? + $debug || ENV["NAROU_ENV"] == "test" end end