class CLI::UI::Spinner::Async
Public Class Methods
new(title)
click to toggle source
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')
# File lib/cli/ui/spinner/async.rb, line 22 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
start(title)
click to toggle source
Convenience method for initialize
# File lib/cli/ui/spinner/async.rb, line 7 def self.start(title) new(title) end
Public Instance Methods
stop()
click to toggle source
Stops an asynchronous spinner
# File lib/cli/ui/spinner/async.rb, line 33 def stop @m.synchronize { @cv.signal } @t.value end