lib/cli/progressbar.rb in request-log-analyzer-1.3.7 vs lib/cli/progressbar.rb in request-log-analyzer-1.4.0

- old
+ new

@@ -35,12 +35,12 @@ attr_accessor :start_time private def fmt_bar bar_width = do_percentage * @terminal_width / 100 - sprintf("[%s%s]", - @bar_mark * bar_width, + sprintf("[%s%s]", + @bar_mark * bar_width, " " * (@terminal_width - bar_width)) end def fmt_percentage do_percentage @@ -49,13 +49,13 @@ def fmt_stat if @finished_p then elapsed else eta end end def fmt_stat_for_file_transfer - if @finished_p then + if @finished_p then sprintf("%s %s %s", bytes, transfer_rate, elapsed) - else + else sprintf("%s %s %s", bytes, transfer_rate, eta) end end def fmt_title @@ -104,11 +104,11 @@ def elapsed elapsed = Time.now - @start_time sprintf("Time: %s", format_time(elapsed)) end - + def eol if @finished_p then "\n" else "\r" end end def do_percentage @@ -118,18 +118,18 @@ @current * 100 / @total end end def show - arguments = @format_arguments.map {|method| + arguments = @format_arguments.map {|method| method = sprintf("fmt_%s", method) send(method) } line = sprintf(@format, *arguments) width = terminal_width(80) - if line.length == width - 1 + if line.length == width - 1 @out.print(line + eol) @out.flush elsif line.length >= width @terminal_width = [@terminal_width - (line.length - width + 1), 0].max if @terminal_width == 0 then @out.print(line + eol) else show end @@ -148,11 +148,11 @@ cur_percentage = (@current * 100 / @total).to_i prev_percentage = (@previous * 100 / @total).to_i end # Use "!=" instead of ">" to support negative changes - if cur_percentage != prev_percentage || + if cur_percentage != prev_percentage || Time.now - @previous_time >= 1 || @finished_p show end end @@ -196,12 +196,12 @@ show_if_needed @previous = @current end def set (count) - count = 0 if count < 0 + count = 0 if count < 0 count = @total if count > @total - + @current = count show_if_needed @previous = @current end