12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/interact/progress.rb', line 12
def start!
@dots ||=
Thread.new do
before_sync = $stdout.sync
$stdout.sync = true
printed = false
i = 1
until @stop_dots
if printed
print "\b" * DOT_COUNT
end
print ("." * i).ljust(DOT_COUNT)
printed = true
if i == DOT_COUNT
i = 0
else
i += 1
end
sleep DOT_TICK
end
if printed
print "\b" * DOT_COUNT
print " " * DOT_COUNT
print "\b" * DOT_COUNT
end
$stdout.sync = before_sync
@stop_dots = nil
end
end
|