lib/cli/progressbar.rb in wvanbergen-request-log-analyzer-1.1.2 vs lib/cli/progressbar.rb in wvanbergen-request-log-analyzer-1.1.3

- old
+ new

@@ -117,35 +117,18 @@ else @current * 100 / @total end end - def get_width - # FIXME: I don't know how portable it is. - default_width = 80 - begin - tiocgwinsz = 0x5413 - data = [0, 0, 0, 0].pack("SSSS") - if @out.ioctl(tiocgwinsz, data) >= 0 then - rows, cols, xpixels, ypixels = data.unpack("SSSS") - if cols >= 0 then cols else default_width end - else - default_width - end - rescue Exception - default_width - end - end - def show arguments = @format_arguments.map {|method| method = sprintf("fmt_%s", method) send(method) } line = sprintf(@format, *arguments) - width = get_width + width = terminal_width(80) 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 @@ -174,10 +157,10 @@ end public def clear @out.print "\r" - @out.print(" " * (get_width - 1)) + @out.print(" " * (terminal_width(80) - 1)) @out.print "\r" end def finish @current = @total