Class: Progress
- Inherits:
-
Object
show all
- Defined in:
- lib/progress.rb
Instance Method Summary
collapse
Constructor Details
#initialize(logfilename) ⇒ Progress
Returns a new instance of Progress.
7
8
9
10
11
12
|
# File 'lib/progress.rb', line 7
def initialize(logfilename)
@last_line = ""
dir = File.dirname(logfilename)
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
@logfile = File.open(logfilename, "w")
end
|
Instance Method Details
#print_line(line) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/progress.rb', line 20
def print_line(line)
@logfile.puts(line)
@logfile.flush()
print "\033[M#{line}\n#{@last_line}"
$stdout.flush()
end
|
#update_last_line(last_line) ⇒ Object
14
15
16
17
18
|
# File 'lib/progress.rb', line 14
def update_last_line(last_line)
@last_line = last_line
print "\033[M#{last_line}"
$stdout.flush()
end
|