Sha256: 1be2738a69952f214a49cd39f1fd3623acc6253373196d6ed744c93182b1d477
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
# typed: true module CLI module UI module Spinner class Async extend T::Sig # Convenience method for +initialize+ # sig { params(title: String).returns(Async) } 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') # sig { params(title: String).void } 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 # sig { returns(T::Boolean) } def stop @m.synchronize { @cv.signal } @t.value end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gorails-0.1.5 | vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb |
gorails-0.1.4 | vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb |
gorails-0.1.3 | vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb |