Sha256: 40e7d4e2d2a5d1879a10bc894c9dea1ed0f103e19ac449d349c8e0da4d8ba524

Contents?: true

Size: 600 Bytes

Versions: 5

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true

require_relative "../../lib/tty-spinner"

def spinner_options
  [
    ":spinner \e[1mNo\e[0m :number Row :line",
    format: :dots,
    error_mark: "✖",
    success_mark: "\e[1m\e[32m✓\e[0m\e[0m"
  ]
end

spinners = TTY::Spinner::Multi.new(*spinner_options)
threads = []

20.times do |i|
  threads << Thread.new do
    spinner = spinners.register(*spinner_options)
    sleep Random.rand(0.1..0.3)

    10.times do
      sleep Random.rand(0.1..0.3)
      spinner.update(number: "(#{i})", line: spinner.row)
      spinner.spin
    end
  end
end

threads.each(&:join)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
planter-cli-3.0.7 lib/tty-spinner/examples/multi/threaded.rb
planter-cli-3.0.5 lib/tty-spinner/examples/multi/threaded.rb
planter-cli-3.0.4 lib/tty-spinner/examples/multi/threaded.rb
planter-cli-3.0.3 lib/tty-spinner/examples/multi/threaded.rb
planter-cli-3.0.2 lib/tty-spinner/examples/multi/threaded.rb