Module: MicroInstall
- Defined in:
- lib/micro_install.rb,
lib/micro_install/spinner.rb,
lib/micro_install/version.rb
Defined Under Namespace
Classes: Installer, LookupError
Constant Summary collapse
- VERSION =
"0.4.0"
Class Method Summary collapse
Class Method Details
.show_wait_spinner(fps = 10) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/micro_install/spinner.rb', line 3 def show_wait_spinner(fps = 10) chars = %w[| / - \\] delay = 1.0 / fps iter = 0 spinner = Thread.new do while iter do # Keep spinning until told otherwise print chars[(iter += 1) % chars.length] sleep delay print "\b" end end yield.tap {# After yielding to the block, save the return value iter = false # Tell the thread to exit, cleaning up after itself… spinner.join # …and wait for it to do so. } # Use the block's return value as the method's end |