piotrmurach/tty-progressbar

View on GitHub
examples/threaded.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

require_relative "../lib/tty-progressbar"

threads = []

bar = TTY::ProgressBar.new("[:bar] :percent", total: 30)

threads << Thread.new do
  15.times { sleep(0.1); bar.update(complete: "-", head: "-"); bar.advance; }
end
threads << Thread.new do
  15.times { sleep(0.1); bar.update(complete: "+", head: "+"); bar.advance; }
end

threads.map(&:join)