Sha256: d3d72db91deaa726778d87a4e76ab3ca2dd294d81a19f384261e930b9c310d11
Contents?: true
Size: 947 Bytes
Versions: 153
Compression:
Stored size: 947 Bytes
Contents
module CLI module UI module Spinner class Async # Convenience method for +initialize+ # def self.start(title) new(title) end # Initializes a new asynchronous spinner with no specific end. # Must call +.stop+ to end the spinner # # ==== Attributes # # * +title+ - Title of the spinner to use # # ==== Example Usage: # # CLI::UI::Spinner::Async.new('Title') # def initialize(title) require 'thread' sg = CLI::UI::Spinner::SpinGroup.new @m = Mutex.new @cv = ConditionVariable.new sg.add(title) { @m.synchronize { @cv.wait(@m) } } @t = Thread.new { sg.wait } end # Stops an asynchronous spinner # def stop @m.synchronize { @cv.signal } @t.value end end end end end
Version data entries
153 entries across 153 versions & 3 rubygems