Method: CLI::UI::Spinner::SpinGroup#add

Defined in:
lib/cli/ui/spinner/spin_group.rb

#add(title, final_glyph: DEFAULT_FINAL_GLYPH, merged_output: false, duplicate_output_to: File.new(File::NULL, 'w'), &block) ⇒ Object

Add a new task

Attributes

  • title - Title of the task

  • block - Block for the task, will be provided with an instance of the spinner

Example Usage:

spin_group = CLI::UI::SpinGroup.new
spin_group.add('Title') { |spinner| sleep 1.0 }
spin_group.wait

: (String title, ?final_glyph: ^(bool success) -> (Glyph | String), ?merged_output: bool, ?duplicate_output_to: IO) { (Task task) -> void } -> void



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/cli/ui/spinner/spin_group.rb', line 304

def add(
  title,
  final_glyph: DEFAULT_FINAL_GLYPH,
  merged_output: false,
  duplicate_output_to: File.new(File::NULL, 'w'),
  &block
)
  @m.synchronize do
    @tasks << Task.new(
      title,
      final_glyph: final_glyph,
      merged_output: merged_output,
      duplicate_output_to: duplicate_output_to,
      work_queue: @work_queue,
      &block
    )
  end
end