class PEROBS::ConsoleProgressMeter
Constants
- LINE_LENGTH
Private Instance Methods
print_bar()
click to toggle source
# File lib/perobs/ConsoleProgressMeter.rb, line 38 def print_bar percent = @max_value == 0 ? 100.0 : (@current_value.to_f / @max_value) * 100.0 percent = 0.0 if percent < 0 percent = 100.0 if percent > 100.0 meter = "<#{percent.to_i}%>" bar_length = LINE_LENGTH - @name.chars.length - 3 - meter.chars.length left_bar = '*' * (bar_length * percent / 100.0) right_bar = ' ' * (bar_length - left_bar.chars.length) print "\r#{@name} [#{left_bar}#{meter}#{right_bar}]" end
print_time()
click to toggle source
# File lib/perobs/ConsoleProgressMeter.rb, line 53 def print_time s = "\r#{@name} [#{secsToHMS(@end_time - @start_time)}]" puts s + (' ' * (LINE_LENGTH - s.chars.length + 1)) end