Class: TTY::Command::Window::Spinner

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/command/window/spinner.rb

Overview

Braille spinner used in block title bars.

Constant Summary collapse

FRAMES =
%w[         ].freeze

Instance Method Summary collapse

Constructor Details

#initializeSpinner

Returns a new instance of Spinner.



10
11
12
# File 'lib/tty/command/window/spinner.rb', line 10

def initialize
  @index = 0
end

Instance Method Details

#frameString

Returns the current frame without advancing.

Returns:

  • (String)

    the current frame without advancing



24
25
26
# File 'lib/tty/command/window/spinner.rb', line 24

def frame
  FRAMES[@index]
end

#tickString

Advance and return the next frame.

Returns:

  • (String)


17
18
19
20
21
# File 'lib/tty/command/window/spinner.rb', line 17

def tick
  frame = FRAMES[@index]
  @index = (@index + 1) % FRAMES.length
  frame
end