Module: CLI::UI::Spinner

Extended by:
T::Sig
Defined in:
lib/cli/ui/spinner.rb,
lib/cli/ui/spinner/async.rb,
lib/cli/ui/spinner/spin_group.rb

Defined Under Namespace

Classes: Async, SpinGroup

Constant Summary collapse

PERIOD =

seconds

0.1
TASK_FAILED =
:task_failed
RUNES =
if CLI::UI::OS.current.use_emoji?
  ['', '', '', '', '', '', '', '', '', ''].freeze
else
  ['\\', '|', '/', '-', '\\', '|', '/', '-'].freeze
end
GLYPHS =
colors.zip(RUNES).map { |c, r| c + r + CLI::UI::Color::RESET.code }.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from T::Sig

sig

Class Attribute Details

.indexObject

Returns the value of attribute index.



31
32
33
# File 'lib/cli/ui/spinner.rb', line 31

def index
  @index
end

Class Method Details

.current_runeObject



44
45
46
# File 'lib/cli/ui/spinner.rb', line 44

def current_rune
  RUNES[index || 0]
end

.spin(title, auto_debrief: true, to: $stdout, &block) ⇒ Object



84
85
86
87
88
# File 'lib/cli/ui/spinner.rb', line 84

def spin(title, auto_debrief: true, to: $stdout, &block)
  sg = SpinGroup.new(auto_debrief: auto_debrief)
  sg.add(title, &block)
  sg.wait(to: to)
end