Class: Utils::Spinner

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/processing_spinner.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpinner

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

.allObject


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

Returns:

  • (Boolean)

22
23
24
# File 'lib/utils/processing_spinner.rb', line 22

def is_processing?
  @processing
end

#start_processingObject


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_processingObject


26
27
28
29
# File 'lib/utils/processing_spinner.rb', line 26

def stop_processing
  @wheel = ''
  @processing = false
end