Class: Bddgenx::Support::Loader
- Inherits:
-
Object
- Object
- Bddgenx::Support::Loader
- Defined in:
- lib/bddgenx/support/loader.rb
Constant Summary collapse
- SPINNERS =
{ default: %w[| / - \\], dots: %w[⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏] }
Class Method Summary collapse
Class Method Details
.run(mensagem = "⏳ Processando...", tipo = :default) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bddgenx/support/loader.rb', line 9 def self.run(mensagem = "⏳ Processando...", tipo = :default) spinner = SPINNERS[tipo] || SPINNERS[:default] done = false thread = Thread.new do i = 0 print "\n" until done print "\r#{mensagem} #{spinner[i % spinner.length]}" sleep(0.1) i += 1 end end result = yield done = true thread.join print "\r#{mensagem} ✅\n" result end |