Sha256: d671b9f43f968a1e2739056e6d11c47c40d80d70502f25ee4e8dca6df3d48091
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# typed: true # frozen_string_literal: true module CLI module UI module Spinner class Async extend T::Sig class << self extend T::Sig # Convenience method for +initialize+ # sig { params(title: String).returns(Async) } def start(title) new(title) end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cli-ui-2.3.0 | lib/cli/ui/spinner/async.rb |