Class: Kafo::ProgressBar
- Inherits:
-
Object
show all
- Defined in:
- lib/kafo/progress_bar.rb
Overview
change more methods like #done_message or #print_error
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ProgressBar.
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/kafo/progress_bar.rb', line 12
def initialize
@lines = 0
@all_lines = 0
@total = :unknown
@term_width = HighLine::SystemExtensions.terminal_size[0] || 0
@bar = PowerBar.new
@bar.settings.tty.infinite.template.main = infinite_template
@bar.settings.tty.finite.template.main = finite_template
@bar.settings.tty.finite.template.padchar = ' '
@bar.settings.tty.finite.template.barchar = '.'
@bar.settings.tty.finite.output = Proc.new { |s| $stderr.print s }
end
|
Instance Method Details
#close ⇒ Object
38
39
40
41
42
43
|
# File 'lib/kafo/progress_bar.rb', line 38
def close
@bar.show({ :msg => done_message,
:done => @total == :unknown ? @bar.done + 1 : @total,
:total => @total }, true)
@bar.close
end
|
#print(line) ⇒ Object
45
46
47
|
# File 'lib/kafo/progress_bar.rb', line 45
def print(line)
@bar.print line
end
|
#print_error(line) ⇒ Object
49
50
51
|
# File 'lib/kafo/progress_bar.rb', line 49
def print_error(line)
print line
end
|
#update(line) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/kafo/progress_bar.rb', line 25
def update(line)
@total = $1.to_i if line =~ /\w*START (\d+)/
@lines += 1 if line.include?('RESOURCE') && @lines < @total - 1
@all_lines += 1
if @all_lines % 20 == 0 || @total != :unknown
@bar.show({ :msg => format(line),
:done => @lines,
:total => @total })
end
end
|