Class: BruteCLI::Spinner::Nyan
- Inherits:
-
Base
- Object
- Base
- BruteCLI::Spinner::Nyan
show all
- Defined in:
- lib/brute_cli/spinner/nyan.rb
Constant Summary
collapse
- RAINBOW =
[
"\e[38;2;255;56;96m", "\e[38;2;255;165;0m",
"\e[38;2;255;220;0m", "\e[38;2;0;219;68m",
"\e[38;2;0;186;255m", "\e[38;2;107;80;255m",
"\e[38;2;255;96;255m",
].freeze
- RESET =
"\e[0m"
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#frames ⇒ Object
41
42
43
44
45
46
|
# File 'lib/brute_cli/spinner/nyan.rb', line 41
def frames
bar = "\u2501" * 12
bar.length.times.map do |offset|
bar.chars.map.with_index { |c, i| RAINBOW[(i + offset) % RAINBOW.length] + c }.join + RESET
end
end
|
#interval ⇒ Object
48
49
50
|
# File 'lib/brute_cli/spinner/nyan.rb', line 48
def interval
8
end
|
#label ⇒ Object
37
38
39
|
# File 'lib/brute_cli/spinner/nyan.rb', line 37
def label
"Thinking..."
end
|
#spinning? ⇒ Boolean
33
34
35
|
# File 'lib/brute_cli/spinner/nyan.rb', line 33
def spinning?
@tty&.spinning? || false
end
|
#start ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/brute_cli/spinner/nyan.rb', line 16
def start
stop if spinning?
@tty = TTY::Spinner.new(
":spinner #{label}",
frames: frames,
interval: interval,
output: @output,
clear: true,
)
@tty.auto_spin
end
|
#stop ⇒ Object
28
29
30
31
|
# File 'lib/brute_cli/spinner/nyan.rb', line 28
def stop
@tty&.stop
@tty = nil
end
|