Class: Fronde::CLI::Throbber
- Inherits:
-
Object
- Object
- Fronde::CLI::Throbber
- Defined in:
- lib/fronde/cli/throbber.rb
Overview
Decorations for the command line
Constant Summary collapse
- THROBBER_FRAMES =
Returns the possible throbber themes.
{ 'basic' => '-\|/', 'basicdots' => 'โฏโฑโฎโฐ', 'moon' => '๐๐๐๐๐๐๐๐', 'clock' => '๐๐๐๐๐๐๐๐๐๐๐๐', 'bricks' => 'โฃทโฃฏโฃโกฟโขฟโฃปโฃฝโฃพ', 'points' => 'ยทโโโ', 'quadrant' => 'โโโโ', 'default' => ['โ โ โ โก โ โ โ ', 'โ โ โ โ โก โ โ ', 'โ โ โ โ โ โก โ ', 'โก โ โ โ โ โ โก', 'โ โก โ โ โ โ โ ', 'โ โ โก โ โ โ โ '] }.freeze
Class Method Summary collapse
-
.run(thread, message, verbose) ⇒ void
Animates strings in the user console to alert him that something is running in the background.
Instance Method Summary collapse
-
#initialize(thread, message) ⇒ Throbber
constructor
A new instance of Throbber.
- #run ⇒ Object
Constructor Details
#initialize(thread, message) ⇒ Throbber
Returns a new instance of Throbber.
22 23 24 25 26 27 28 29 |
# File 'lib/fronde/cli/throbber.rb', line 22 def initialize(thread, ) @frames = select_frames @term_width = terminal_width @thread = thread @thread.abort_on_exception = false @thread.report_on_exception = false @message = end |
Class Method Details
.run(thread, message, verbose) ⇒ void
This method returns an undefined value.
Animates strings in the user console to alert him that something
is running in the background.
The animation is chosen among a bunch of themes, with the configuration option ~throbber~ (retrieved via Fronde::Config::Store#get).
62 63 64 65 66 67 68 69 |
# File 'lib/fronde/cli/throbber.rb', line 62 def run(thread, , verbose) if verbose thread.join else throbber = new(thread, ) throbber.run end end |
Instance Method Details
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fronde/cli/throbber.rb', line 31 def run thread_loop rescue RuntimeError => e show_error raise e # :nocov: not sure how to emulate a Ctrl+c in rspec rescue Interrupt => e Rainbow(I18n.t('fronde.bin.interrupted')).red, "\n" raise e # :nocov: else Rainbow(I18n.t('fronde.bin.done')).green, "\n" end |