Class: Utils::Spinner
- Inherits:
-
Object
- Object
- Utils::Spinner
- Defined in:
- lib/utils/processing_spinner.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Spinner
constructor
A new instance of Spinner.
- #is_processing? ⇒ Boolean
- #start_processing ⇒ Object
- #stop_processing ⇒ Object
Constructor Details
#initialize ⇒ Spinner
Returns a new instance of Spinner.
4 5 6 7 |
# File 'lib/utils/processing_spinner.rb', line 4 def initialize @wheel = '' @processing = false end |
Class Method Details
.all ⇒ Object
18 19 20 |
# File 'lib/utils/processing_spinner.rb', line 18 def self.all ObjectSpace.each_object(self).to_a end |
Instance Method Details
#is_processing? ⇒ Boolean
22 23 24 |
# File 'lib/utils/processing_spinner.rb', line 22 def is_processing? @processing end |
#start_processing ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/utils/processing_spinner.rb', line 9 def start_processing @wheel = %w{| / - \\} @processing = true while @processing do print "\b" + @wheel.rotate!.first sleep(0.1) end end |
#stop_processing ⇒ Object
26 27 28 29 |
# File 'lib/utils/processing_spinner.rb', line 26 def stop_processing @wheel = '' @processing = false end |