### Install TTY::Spinner Gem Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Instructions for installing the TTY::Spinner gem using Bundler or directly via the gem command. This is the first step to using the library in a Ruby project. ```ruby gem "tty-spinner" ``` ```shell gem install tty-spinner ``` -------------------------------- ### Initialize and Use TTY::Spinner Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Demonstrates basic initialization of a TTY::Spinner, starting automatic animation, performing a task, and stopping the animation with a final message. Shows how to create a spinner with a custom message and format. ```ruby spinner = TTY::Spinner.new ``` ```ruby spinner = TTY::Spinner.new("[:spinner] Loading ...", format: :pulse_2) spinner.auto_spin # Automatic animation with default interval sleep(2) # Perform task spinner.stop("Done!") # Stop animation ``` -------------------------------- ### Start and Stop Spinner (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Manually starts and stops the spinner animation. The `start` method initiates the animation, and the `stop` method terminates it, optionally with a message. This is useful for reusing a spinner or controlling its start time. ```ruby spinner.start ``` ```ruby spinner.stop ``` ```ruby spinner.stop("Done!") ``` -------------------------------- ### Threaded Multi-spinner with Dynamic Updates Source: https://context7.com/piotrmurach/tty-spinner/llms.txt An advanced example showcasing threaded spinners within TTY::Spinner::Multi, featuring dynamic token updates during animation. This demonstrates complex concurrent operations with visual feedback. ```ruby require "tty-spinner" def spinner_options [ ":spinner No :number Row :line", format: :dots, error_mark: "✖", success_mark: "✓" ] end spinners = TTY::Spinner::Multi.new(*spinner_options) threads = [] 20.times do |i| threads << Thread.new do spinner = spinners.register(*spinner_options) sleep(rand(0.1..0.3)) 10.times do sleep(rand(0.1..0.3)) spinner.update(number: "(#{i})", line: spinner.row) spinner.spin end end end threads.each(&:join) ``` -------------------------------- ### Initialize TTY::Spinner::Multi with Top-Level Spinner Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Initializes a TTY::Spinner::Multi instance with a message for a top-level spinner. This top-level spinner animates automatically when any registered spinner starts. ```ruby multi_spinner = TTY::Spinner::Multi.new("[:spinner] Top level spinner") ``` -------------------------------- ### Manual Async Spinner Control with TTY::Spinner::Multi Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Demonstrates manual control over multiple spinners within a TTY::Spinner::Multi instance. Spinners are registered, started manually using `auto_spin`, and stopped individually with `success` or `error`. ```ruby multi_spinner = TTY::Spinner::Multi.new("[:spinner] top") spinner_1 = multi_spinner.register "[:spinner] one" spinner_2 = multi_spinner.register "[:spinner] two" spinner_1.auto_spin spinner_2.auto_spin spinner_1.success spinner_2.error ``` -------------------------------- ### Execute Block with Spinner Animation using run Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Demonstrates the `run` method, which automatically starts a spinner, executes a given block of code, and then stops the spinner upon completion. This is the most straightforward way to wrap synchronous tasks with visual feedback. ```ruby require "tty-spinner" spinner = TTY::Spinner.new(":title :spinner ...", format: :pulse_3) def long_task 10_000_000.times { |n| n * n } end # Execute task with animation spinner.update(title: "Task 1") spinner.run("done") do long_task end # Output: Task 1 ▌ ... done # Reuse spinner for another task spinner.update(title: "Task 2") spinner.run("done") { long_task } # Output: Task 2 ▌ ... done ``` -------------------------------- ### Manage Multiple Parallel Spinners with TTY::Spinner::Multi Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Introduces TTY::Spinner::Multi for managing multiple concurrent spinners with a hierarchical tree-style display. This example demonstrates manual control using threads and registering child spinners. ```ruby require "tty-spinner" # Multi-spinner with top-level parent spinners = TTY::Spinner::Multi.new("[:spinner] top") # Register child spinners sp1 = spinners.register("[:spinner] one") sp2 = spinners.register("[:spinner] two") sp3 = spinners.register("[:spinner] three") # Manual control with threads th1 = Thread.new { sleep(2); sp1.success } th2 = Thread.new { sleep(3); sp2.error } th3 = Thread.new { sleep(1); sp3.success } sp1.auto_spin sp2.auto_spin sp3.auto_spin [th1, th2, th3].each(&:join) # Output: # ┌ [✖] top # ├── [✔] one # ├── [✖] two # └── [✔] three ``` -------------------------------- ### Automatic Spinner Animation with auto_spin Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Shows how to start an automatic spinner animation in a background thread using `auto_spin`. The animation runs independently until explicitly stopped, suitable for long-running tasks where manual frame control is not needed. ```ruby require "tty-spinner" spinner = TTY::Spinner.new("Loading :spinner ...", format: :bouncing_ball) # Start automatic animation spinner.auto_spin # Perform your long-running task sleep(2) # Simulated work # Stop with message spinner.stop("done") # Output: Loading ( ● ) ... done ``` -------------------------------- ### Get Animation Duration Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Retrieves the duration of the spinner's animation in seconds since it started. ```ruby spinner.duration # => Float (seconds since start) ``` -------------------------------- ### Configure Spinner Output Stream (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Specifies the output stream for the spinner using the `:output` option. By default, spinners do not output to files or pipes to avoid cluttering logs. This option allows redirecting output, for example, to `$stdout`. ```ruby spinner = TTY::Spinner.new(output: $stdout) ``` -------------------------------- ### Create TTY::Spinner Instance Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Demonstrates how to create a TTY::Spinner instance with various configuration options. This includes setting a custom message, choosing a spinner format, defining animation speed, cursor visibility, and output streams. ```ruby require "tty-spinner" # Basic spinner with default classic format (| / - \) spinner = TTY::Spinner.new # Spinner with message and format spinner = TTY::Spinner.new("[:spinner] Loading ...", format: :pulse_2) # Fully configured spinner with all options spinner = TTY::Spinner.new( "[:spinner] Processing :title ...", format: :dots, # Predefined format (see formats below) frames: nil, # Custom frames array (overrides format) interval: 10, # Animation speed in Hz (frames per second) hide_cursor: true, # Hide terminal cursor during animation clear: false, # Clear spinner output when finished success_mark: "✔", # Mark shown on success error_mark: "✖", # Mark shown on error output: $stderr # Output stream (default: $stderr) ) ``` -------------------------------- ### Utilize Predefined Spinner Formats Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Explains how to use the numerous predefined spinner formats available in the TTY::Spinner gem. The `:format` option can be set during spinner initialization, and custom frames can also be provided. ```ruby require "tty-spinner" # Common formats formats = [ :classic, # | / - \ :spin, # ◴ ◷ ◶ ◵ :spin_2, # ◐ ◓ ◑ ◒ :dots, # ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ :dots_2, # ⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷ :pulse, # ⎺ ⎻ ⎼ ⎽ ⎼ ⎻ :pulse_2, # ▁ ▃ ▅ ▆ ▇ █ ▇ ▆ ▅ ▃ :pulse_3, # ▉ ▊ ▋ ▌ ▍ ▎ ▏ ▎ ▍ ▌ ▋ ▊ ▉ :arrow, # ← ↖ ↑ ↗ → ↘ ↓ ↙ :arrow_pulse, # ▹▹▹▹▹ ▸▹▹▹▹ ▹▸▹▹▹ ... :triangle, # ◢ ◣ ◤ ◥ :arc, # ◜ ◠ ◝ ◞ ◡ ◟ :pipe, # ┤ ┘ ┴ └ ├ ┌ ┬ ┐ :bouncing, # [ ] [ =] [ ==] ... :bouncing_ball, # ( ● ) ( ● ) ... :star, # ✶ ✸ ✹ ✺ ✹ ✷ :toggle, # ■ □ ▪ ▫ :balloon, # . o O @ * :shark, # Swimming shark animation :pong # Bouncing ball animation ] # Custom frames spinner = TTY::Spinner.new( "[:spinner] Custom", frames: [".", "o", "0", "@", "*"] ) ``` -------------------------------- ### Spinner Utility Methods Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Provides an overview of additional utility methods available for managing spinner state and querying information within TTY::Spinner. These methods aid in controlling and monitoring spinner behavior. ```ruby require "tty-spinner" spinner = TTY::Spinner.new("[:spinner] Task") spinner.auto_spin ``` -------------------------------- ### Event Handling Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Callbacks can be registered to respond to 'success' and 'error' events fired by the spinner. ```APIDOC ## Event Handling ### Description Callbacks can be registered to respond to specific events like 'success' and 'error'. ### Method `spinner.on(event_name) { ... }` ### Events - **:success**: Fired when the `success` method is called on the spinner. - **:error**: Fired when the `error` method is called on the spinner. ### Example ```ruby spinner.on(:success) { puts "Task completed successfully!" } spinner.on(:error) { puts "Task failed." } ``` ``` -------------------------------- ### TTY::Spinner::Multi API Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Manage and control multiple spinners simultaneously using the TTY::Spinner::Multi class. ```APIDOC ## TTY::Spinner::Multi API ### Description The `TTY::Spinner::Multi` class allows for the management and display of multiple spinners, providing a way to track the progress of several concurrent tasks. ### 5.1 register #### Description Registers a new `TTY::Spinner` instance with a `TTY::Spinner::Multi` instance. Options can be provided to customize the new spinner, overriding the multi-spinner's default options. #### Method `multi_spinner.register(spinner_or_text, options = {})` #### Parameters - **spinner_or_text** (TTY::Spinner or String) - An existing `TTY::Spinner` instance or a text string for a new spinner. - **options** (Hash) - Optional. Configuration options for the new spinner. #### Example ```ruby # Registering with text and options new_spinner = multi_spinner.register("[:spinner] Task 1 name", { interval: 100 }) # Registering an existing spinner spinner = ::TTY::Spinner.new("[:spinner] one") sp1 = multi_spinner.register(spinner) ``` ### 5.2 auto_spin #### Description Initiates the automatic spinning animation for the multi-spinner and its registered sub-spinners. This method is particularly useful when dealing with asynchronous tasks. #### Usage - If the `multi_spinner` was initialized with a message, it will act as a top-level tracker. - If registered spinners have tasks, they will animate and finish automatically. - If spinners are registered without tasks, manual control (`stop`, `success`, `error`) is required. #### Example ```ruby multi_spinner = TTY::Spinner::Multi.new("[:spinner] Top level spinner") multi_spinner.auto_spin ``` #### 5.2.1 manual async ##### Description Provides full control over multiple spinners, requiring manual initiation and completion of each spinner. ##### Example ```ruby multi_spinner = TTY::Spinner::Multi.new("[:spinner] top") spinner_1 = multi_spinner.register("[:spinner] one") spinner_2 = multi_spinner.register("[:spinner] two") spinner_1.auto_spin spinner_2.auto_spin # Manually stop spinners spinner_1.success spinner_2.error ``` #### 5.2.2 auto async tasks ##### Description Executes asynchronous tasks associated with registered spinners and automatically updates their status. Spinners are updated based on the completion of their respective tasks. ##### Example ```ruby multi_spinner = TTY::Spinner::Multi.new("[:spinner] top") multi_spinner.register("[:spinner] one") { |sp| sleep(2); sp.success("yes 2") } multi_spinner.register("[:spinner] two") { |sp| sleep(3); sp.error("no 2") } multi_spinner.auto_spin ``` ### 5.3 stop #### Description Stops the multi-spinner and any sub-spinners that are currently spinning. #### Method `multi_spinner.stop` #### Example ```ruby multi_spinner.stop ``` #### 5.3.1 success ##### Description Stops the spinning animation, replaces the spinner symbol with a check mark to indicate success, and calls `#success` on any active sub-spinners. ##### Method `multi_spinner.success` ##### Example ```ruby multi_spinner.success ``` #### 5.3.2 error ##### Description Stops the spinning animation, replaces the spinner symbol with a cross character to indicate an error, and calls `#error` on any active sub-spinners. ##### Method `multi_spinner.error` ##### Example ```ruby multi_spinner.error ``` ### 5.4 :style #### Description Allows customization of the multi-spinner's appearance using style options, overriding default characters for top, middle, and bottom elements. #### Parameters - **style** (Hash) - A hash containing style configurations: - **top** (String): Character(s) for the top element. - **middle** (String): Character(s) for the middle elements. - **bottom** (String): Character(s) for the bottom element. #### Example ```ruby multi_spinner = TTY::Spinner::Multi.new("[:spinner] parent", style: { top: ". " middle: "|-> " bottom: "|__ " }) ``` ``` -------------------------------- ### Register Callbacks for Spinner Events Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Shows how to register callback functions for various TTY::Spinner events, including `:spin`, `:done`, `:success`, and `:error`. These callbacks allow for custom actions upon spinner completion or state changes. ```ruby require "tty-spinner" spinner = TTY::Spinner.new("[:spinner] Processing") # Register event handlers spinner.on(:done) { puts "\nSpinner finished!" } spinner.on(:success) { puts "Task succeeded!" } spinner.on(:error) { puts "Task failed!" } spinner.auto_spin sleep(1) spinner.success # Output: # [✔] Processing # Task succeeded! # Spinner finished! ``` -------------------------------- ### Customize Multi-spinner Tree Style Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Demonstrates how to customize the tree-style indentation characters used by TTY::Spinner::Multi. This allows for different visual styles for the hierarchical display. ```ruby require "tty-spinner" spinners = TTY::Spinner::Multi.new( "[:spinner] parent", style: { top: ". ", middle: "|-> ", bottom: "|__ " } ) sp1 = spinners.register("[:spinner] child 1") sp2 = spinners.register("[:spinner] child 2") sp1.auto_spin sp2.auto_spin sleep(1) sp1.success sp2.success # Output: # . [✔] parent # |-> [✔] child 1 # |__ [✔] child 2 ``` -------------------------------- ### Style TTY::Spinner::Multi Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Applies custom styling to the TTY::Spinner::Multi instance using a hash of style options. This allows for customization of the appearance of the top, middle, and bottom elements of the multi-spinner output. ```ruby multi_spinner = TTY::Spinner::Multi.new("[:spinner] parent", style: { top: ". " middle: "|-> " bottom: "|__ " }) ``` -------------------------------- ### Manual Spinner Animation with spin Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Illustrates manual control over spinner animation using the `spin` method. This requires calling `spin` within a loop to advance the animation frame by frame, allowing for custom timing and control. ```ruby require "tty-spinner" spinner = TTY::Spinner.new("Loading :spinner ... ", format: :spin_2) # Manual animation loop 20.times do spinner.spin sleep(0.1) end spinner.stop("done") # Output: Loading ◑ ... done ``` -------------------------------- ### Spinner Completion with success and error Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Explains how to use the `success` and `error` methods to stop a spinner and indicate task completion with specific marks. These methods also trigger corresponding events for callback handling and allow for custom completion messages. ```ruby require "tty-spinner" # Success example spinner = TTY::Spinner.new("[:spinner] Downloading files") spinner.auto_spin sleep(1) # Simulated download spinner.success("(completed)") # Output: [✔] Downloading files (completed) # Error example spinner = TTY::Spinner.new("[:spinner] Connecting to server") spinner.auto_spin sleep(1) # Simulated connection attempt spinner.error("(connection refused)") # Output: [✖] Connecting to server (connection refused) # Custom marks spinner = TTY::Spinner.new( "[:spinner] Task", success_mark: "+", error_mark: "x" ) spinner.auto_spin sleep(1) spinner.success # Output: [+] Task ``` -------------------------------- ### Pause and Resume Spinner Animation Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Demonstrates how to temporarily pause and resume a TTY::Spinner animation. The spinner displays a static frame while paused and can be resumed with an optional custom mark. ```ruby require "tty-spinner" spinner = TTY::Spinner.new("[:spinner] :title") spinner.update(title: "Task name") spinner.auto_spin sleep(2) # Pause with custom mark spinner.update(title: "Paused task name") spinner.pause(mark: "?") # Output: [?] Paused task name sleep(2) # Resume animation spinner.resume spinner.update(title: "Task name") sleep(2) spinner.stop("done...") # Output: [|] Task name done... ``` -------------------------------- ### Configure Spinner Format and Frames (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Customizes the spinner's appearance using predefined formats like `:pulse_2` or by providing a custom array or string of characters for the `:frames` option. The available formats are defined in the gem's source code. ```ruby spinner = TTY::Spinner.new(format: :pulse_2) ``` ```ruby spinner = TTY::Spinner.new(frames: [".", "o", "0", "@", "*"]) ``` -------------------------------- ### Multi-spinner with Automatic Jobs Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Illustrates using TTY::Spinner::Multi to manage spinners that execute as asynchronous jobs defined by blocks. The multi-spinner automatically handles animation and completion of these jobs. ```ruby require "tty-spinner" spinners = TTY::Spinner::Multi.new("[:spinner] top") # Register spinners with jobs (blocks receive the spinner instance) spinners.register("[:spinner] one") { |sp| sleep(2); sp.success("yes 2") } spinners.register("[:spinner] two") { |sp| sleep(3); sp.error("no 2") } spinners.register("[:spinner] three") { |sp| sleep(1); sp.success("yes 3") } # Start all jobs concurrently spinners.auto_spin # Output (after completion): # ┌ [✖] top # ├── [✔] one yes 2 # ├── [✖] two no 2 # └── [✔] three yes 3 ``` -------------------------------- ### Configure Spinner Clear and Marks (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Determines whether the spinner's output should be cleared after completion using the `:clear` option. Custom characters for success (`:success_mark`) and error (`:error_mark`) indicators can also be specified. ```ruby spinner = TTY::Spinner.new(clear: true) ``` ```ruby spinner = TTY::Spinner.new(success_mark: "+") ``` ```ruby spinner = TTY::Spinner.new(error_mark: "x") ``` -------------------------------- ### Register Spinner with TTY::Spinner::Multi Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Creates and registers a new TTY::Spinner instance within a TTY::Spinner::Multi instance. It can accept a format string and options, or an existing spinner object. Options provided here override those of the parent multi_spinner. ```ruby new_spinner = multi_spinner.register("[:spinner] Task 1 name", options) # or # spinner = ::TTY::Spinner.new("[:spinner] one") # sp1 = multi_spinner.register(spinner) ``` -------------------------------- ### Handle Spinner Success Event Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Registers a callback to be executed when the spinner's success event is triggered. This allows for custom actions upon successful completion of a task. ```ruby spinner.on(:success) { ... } ``` -------------------------------- ### Auto Async Tasks with TTY::Spinner::Multi Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Executes asynchronous tasks and automatically updates individual spinners using TTY::Spinner::Multi. The `#register` method accepts a block representing the task, and `#auto_spin` initiates the process. ```ruby multi_spinner = TTY::Spinner::Multi.new("[:spinner] top") multi_spinner.register("[:spinner] one") { |sp| sleep(2); sp.success("yes 2") } multi_spinner.register("[:spinner] two") { |sp| sleep(3); sp.error("no 2") } multi_spinner.auto_spin ``` -------------------------------- ### Configure Spinner Interval and Cursor (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Adjusts the animation speed with the `:interval` option (in Hz) and controls cursor visibility during animation using `:hide_cursor`. Setting `hide_cursor` to `true` improves the visual experience by hiding the blinking cursor. ```ruby spinner = TTY::Spinner.new(interval: 20) # 20 Hz (20 times per second) ``` ```ruby spinner = TTY::Spinner.new(hide_cursor: true) ``` -------------------------------- ### Join Animation Thread Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Waits for the animation thread to complete. An optional timeout can be provided to limit the waiting period. ```ruby spinner.join spinner.join(0.5) # With timeout ``` -------------------------------- ### Run Spinner with Block (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Executes a block of code while displaying a spinning animation. The spinner instance is yielded to the block. The animation stops automatically when the block terminates. An optional stop message can be provided. ```ruby spinner.run do |spinner| # ... code to execute while spinning end ``` ```ruby spinner.run("Done!") do |spinner| # ... code to execute while spinning end ``` -------------------------------- ### Dynamically Update Spinner Labels with update Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Illustrates the `update` method for dynamically changing token values within the spinner's message during animation. This is useful for displaying real-time progress or updating task descriptions without restarting the spinner. ```ruby require "tty-spinner" spinner = TTY::Spinner.new(":spinner :title", format: :pulse_3) # Set initial title spinner.update(title: "task aaaaa") 20.times { spinner.spin; sleep(0.1) } # Update title mid-animation spinner.update(title: "task b") 20.times { spinner.spin; sleep(0.1) } spinner.stop ``` -------------------------------- ### Register Spinner Event Callbacks (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Allows registering callback functions for spinner events like `:done`, `:success`, and `:error`. The `:done` event is emitted regardless of how the spinner is stopped, providing a universal hook for cleanup or finalization. ```ruby spinner.on(:done) { # ... callback code ... } ``` -------------------------------- ### Stop TTY::Spinner::Multi Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Stops the multi spinner, including the top-level spinner if it exists, and any sub-spinners that are still active. This is a general-purpose stop method. ```ruby multi_spinner.stop ``` -------------------------------- ### Reset and Join Spinner Threads (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Resets the spinner to its initial frame using `reset`. The `join` method waits for the spinner's thread to complete, optionally with a timeout, ensuring the main program doesn't exit before the spinner finishes. ```ruby spinner.reset ``` ```ruby spinner.join ``` ```ruby spinner.join(0.5) ``` -------------------------------- ### Handle Spinner Error Event Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Registers a callback to be executed when the spinner's error event is triggered. This is useful for performing specific actions when a task fails. ```ruby spinner.on(:error) { ... } ``` -------------------------------- ### Check TTY Output and Log Messages (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md The `tty?` method checks if the output stream is a terminal, preventing output when redirected. The `log` method prints messages above the spinner, useful for status updates without interrupting the animation. ```ruby spinner.tty? ``` ```ruby spinner.log("Print this log message to the console") ``` -------------------------------- ### Check Spinner States Source: https://context7.com/piotrmurach/tty-spinner/llms.txt These methods allow you to check the current state of the spinner, such as whether it is currently animating, has finished, is paused, or has encountered an error. ```ruby spinner.spinning? # => true (while animating) spinner.done? # => false (until stopped) spinner.paused? # => false spinner.success? # => false (until success called) spinner.error? # => false (until error called) ``` -------------------------------- ### Mark TTY::Spinner::Multi as Success Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Stops the spinning animation for the multi spinner and its sub-spinners, replacing the spinning symbol with a check mark to indicate overall success. It calls `#success` on any active sub-spinners. ```ruby multi_spinner.success ``` -------------------------------- ### Kill Animation Thread Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Immediately terminates the animation thread, stopping the spinner. ```ruby spinner.kill ``` -------------------------------- ### Reset Spinner Animation Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Resets the spinner to its initial frame, effectively restarting the animation sequence without stopping the process. ```ruby spinner.reset ``` -------------------------------- ### Indicate Spinner Success or Error (Ruby) Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Stops the spinner animation and replaces the spinning symbol with a success check mark or an error cross. This visually communicates the outcome of a task. A custom message can be appended. ```ruby spinner = TTY::Spinner.new("[:spinner] Task name") spinner.success("(successful)") ``` ```ruby spinner = TTY::Spinner.new("[:spinner] Task name") spinner.error("(error)") ``` -------------------------------- ### Check TTY Output Source: https://context7.com/piotrmurach/tty-spinner/llms.txt This method checks if the output stream for the spinner is a TTY (teletypewriter), which is important for determining if visual elements like spinners should be displayed. ```ruby spinner.tty? # => true/false ``` -------------------------------- ### Mark TTY::Spinner::Multi as Error Source: https://github.com/piotrmurach/tty-spinner/blob/master/README.md Stops the spinning animation for the multi spinner and its sub-spinners, replacing the spinning symbol with a cross to indicate an error. It calls `#error` on any active sub-spinners. ```ruby multi_spinner.error ``` -------------------------------- ### Stop Spinner Source: https://context7.com/piotrmurach/tty-spinner/llms.txt Stops the spinner animation. This is typically called after the operation it was monitoring has completed. ```ruby sleep(1) spinner.stop ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.