lib/progress_bar.rb in progress_bar-1.0.0 vs lib/progress_bar.rb in progress_bar-1.0.1

- old
+ new

@@ -13,19 +13,19 @@ @meters = [:bar, :counter, :percentage, :elapsed, :eta, :rate] @max = args.shift if args.first.is_a? Numeric @meters = args unless args.empty? - @last_write = Time.at(0) - @start = Time.now + @last_write = ::Time.at(0) + @start = ::Time.now @hl = HighLine.new end def increment!(count = 1) self.count += count - now = Time.now + now = ::Time.now if (now - @last_write) > 0.2 || self.count >= max write @last_write = now end end @@ -46,11 +46,11 @@ def percentage ratio * 100 end def elapsed - Time.now - @start + ::Time.now - @start end def rate if count > 0 count / elapsed @@ -121,11 +121,11 @@ "[%#{max_width+3}.2f/s]" % rate end def terminal_width # HighLine check takes a long time, so only update width every second. - if @last_width_adjustment.nil? || Time.now - @last_width_adjustment > 1 - @last_width_adjustment = Time.now + if @last_width_adjustment.nil? || ::Time.now - @last_width_adjustment > 1 + @last_width_adjustment = ::Time.now @terminal_width = @hl.output_cols.to_i if @terminal_width < 1 @terminal_width = 80 end @terminal_width