Skip to content
Browse files

Actually support multiple bars.

  • Loading branch information...
1 parent c3567b4 commit 6880e739aeee8f2ca8b6926943e676ea436f2e4c @Peeja committed Nov 15, 2009
Showing with 9 additions and 5 deletions.
  1. +4 −1 lib/multi_progress_bar/bar.rb
  2. +5 −4 progress_bar.rb
View
5 lib/multi_progress_bar/bar.rb
@@ -1,7 +1,10 @@
module MultiProgressBar
class Bar < DelegateClass(BarRenderer)
+ BARS = []
+
def initialize(title, total)
- @window = Ncurses::WINDOW.new(1, 0, 0, 0)
+ BARS << self
+ @window = Ncurses::WINDOW.new(1, 0, BARS.index(self), 0)
renderer = BarRenderer.new(title, total, @window.getmaxx) do |bar|
@window.addstr(bar)
View
9 progress_bar.rb
@@ -17,12 +17,13 @@
info_win.refresh
end
- bar = MultiProgressBar::Bar.new("lapidge", 100)
-
# Demo.
- until bar.current == bar.total do
+ bleeker = MultiProgressBar::Bar.new("bleeker", 100)
+ montrose = MultiProgressBar::Bar.new("montrose", 100)
+ until bleeker.current == bleeker.total && montrose.current == montrose.total
sleep(0.1)
- bar.inc(rand(5))
+ bleeker.inc(rand(5))
+ montrose.inc(rand(5))
end
ensure
MultiProgressBar.end

0 comments on commit 6880e73

Please sign in to comment.
Something went wrong with that request. Please try again.