class Toys::Utils::Terminal

def spinner(leading_text: "", final_text: "",

Returns:
  • (Object) - The return value of the block.

Parameters:
  • final_text (String) -- Optional final string to display when the
  • style (Symbol, Array) -- A terminal style or array of styles
  • frames (Array) -- An array of frames. Defaults to
  • frame_length (Float) -- Length of a single frame, in seconds.
  • leading_text (String) -- Optional leading string to display to the
def spinner(leading_text: "", final_text: "",
            frame_length: nil, frames: nil, style: nil)
  return nil unless block_given?
  frame_length ||= DEFAULT_SPINNER_FRAME_LENGTH
  frames ||= DEFAULT_SPINNER_FRAMES
  write(leading_text) unless leading_text.empty?
  spin = SpinDriver.new(self, frames, Array(style), frame_length)
  begin
    yield
  ensure
    spin.stop
    write(final_text) unless final_text.empty?
  end
end