Class: ProgressBarManager
- Inherits:
-
Object
- Object
- ProgressBarManager
- Includes:
- Singleton
- Defined in:
- lib/progress_bar.rb
Overview
Instance Method Summary collapse
- #add(title, total1) ⇒ Object
- #flush ⇒ Object
-
#initialize ⇒ ProgressBarManager
constructor
A new instance of ProgressBarManager.
- #outio ⇒ Object
- #print(title) ⇒ Object
Constructor Details
#initialize ⇒ ProgressBarManager
Returns a new instance of ProgressBarManager.
313 314 315 316 317 |
# File 'lib/progress_bar.rb', line 313 def initialize @finished = {} = {} @outs = {} end |
Instance Method Details
#add(title, total1) ⇒ Object
319 320 321 322 323 324 325 |
# File 'lib/progress_bar.rb', line 319 def add(title, total1) # if(@bars[title]) # raise StandardError.new # end @outs[title] = ProgressBarOutputStream.new(self) [title] = ProgressBarImpl.new(title, total1, @outs[title]) end |
#flush ⇒ Object
339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/progress_bar.rb', line 339 def flush .keys.each do |title| print(title) end .values.each do || if(.finished?) print(.title) outio.print "\n" @outs.delete(.title) .delete(.title) end end end |
#outio ⇒ Object
335 336 337 |
# File 'lib/progress_bar.rb', line 335 def outio ProgressBar.outio end |
#print(title) ⇒ Object
327 328 329 330 331 332 333 |
# File 'lib/progress_bar.rb', line 327 def print(title) str = '' str += @outs[title].to_s str += "\r" outio.print "\r" outio.print str end |