How TTY::ProgressBar::Multi works
masterThe TTY::ProgressBar::Multi class allows you to display multiple progress bars in parallel. You first create a top-level Multi instance (which acts as a container) and then register child bars using the register method. Calling start on the multi-bar instance begins the timers for all registered bars.
# Declare a top level bar and then register child bars
bars = TTY::ProgressBar::Multi.new("main [:bar] :percent")
bar1 = bars.register("one [:bar] :percent", total: 15)
bar2 = bars.register("two [:bar] :percent", total: 15)
# starts all registered bars timers
bars.start
# Progress child bars in parallel (e.g., using threads)
th1 = Thread.new { 15.times { sleep(0.1); bar1.advance } }
th2 = Thread.new { 15.times { sleep(0.1); bar2.advance } }
[th1, th2].each { |t| t.join }