class Dev::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:

Dev::UI::Spinner::Async.new('Title')
# File lib/dev/ui/spinner/async.rb, line 22
def initialize(title)
  require 'thread'
  sg = Dev::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/dev/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/dev/ui/spinner/async.rb, line 33
def stop
  @m.synchronize { @cv.signal }
  @t.value
end