Method: WebTranslateIt::CommandLine#throb
- Defined in:
- lib/web_translate_it/command_line.rb
#throb ⇒ Object
rubocop:todo Metrics/AbcSize, Metrics/MethodLength
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/web_translate_it/command_line.rb', line 458 def throb # rubocop:todo Metrics/AbcSize, Metrics/MethodLength throb = %w[⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏] throb.reverse! if rand > 0.5 i = rand throb.length thread = Thread.new do dot = lambda do print "\r#{throb[i]}\e[?25l" i = (i + 1) % throb.length sleep 0.1 and dot.call end dot.call end yield ensure if thread thread.kill puts "\r\e[0G#\e[?25h" end end |