Class: CC::Analyzer::Formatters::Spinner
- Inherits:
-
Object
- Object
- CC::Analyzer::Formatters::Spinner
- Defined in:
- lib/cc/analyzer/formatters/spinner.rb
Instance Method Summary collapse
-
#initialize(text) ⇒ Spinner
constructor
A new instance of Spinner.
- #start ⇒ Object
- #stop(text = "Done!") ⇒ Object
Constructor Details
#initialize(text) ⇒ Spinner
Returns a new instance of Spinner.
5 6 7 |
# File 'lib/cc/analyzer/formatters/spinner.rb', line 5 def initialize(text) @spinner = TTY::Spinner.new(text) end |
Instance Method Details
#start ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cc/analyzer/formatters/spinner.rb', line 9 def start return unless $stdout.tty? && !CLI.debug? @thread = Thread.new do loop do @spinning = true spinner.spin sleep 0.075 end end end |
#stop(text = "Done!") ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/cc/analyzer/formatters/spinner.rb', line 20 def stop(text = "Done!") if @spinning spinner.stop(text) print("\n") @thread.kill end @spinning = false end |