Class: Progress
- Inherits:
-
Object
- Object
- Progress
- Defined in:
- lib/progress.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(logfilename) ⇒ Progress
constructor
A new instance of Progress.
- #print_line(line) ⇒ Object
- #update_last_line(last_line) ⇒ Object
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 |