Class: Pcli::SimpleSpinnerBar
- Inherits:
-
Object
- Object
- Pcli::SimpleSpinnerBar
- Defined in:
- lib/pcli/simple_spinner_bar.rb
Class Method Summary collapse
Instance Method Summary collapse
- #failure(new_template = false) ⇒ Object
-
#initialize(template, output) ⇒ SimpleSpinnerBar
constructor
A new instance of SimpleSpinnerBar.
- #start ⇒ Object
- #success(new_template = false) ⇒ Object
Constructor Details
#initialize(template, output) ⇒ SimpleSpinnerBar
Returns a new instance of SimpleSpinnerBar.
9 10 11 12 13 14 15 16 17 |
# File 'lib/pcli/simple_spinner_bar.rb', line 9 def initialize(template, output) @template = template @spinner = TTY::Spinner.new( '[:spinner] :template', format: :dots, interval: 20, output: output ) end |
Class Method Details
.start(template, output) ⇒ Object
5 6 7 |
# File 'lib/pcli/simple_spinner_bar.rb', line 5 def self.start(template, output) new(template, output).tap(&:start) end |
Instance Method Details
#failure(new_template = false) ⇒ Object
29 30 31 32 |
# File 'lib/pcli/simple_spinner_bar.rb', line 29 def failure(new_template = false) spinner.update(template: new_template) if new_template spinner.error(Pl.red('(failed)')) end |
#start ⇒ Object
19 20 21 22 |
# File 'lib/pcli/simple_spinner_bar.rb', line 19 def start spinner.update(template: template) spinner.auto_spin end |
#success(new_template = false) ⇒ Object
24 25 26 27 |
# File 'lib/pcli/simple_spinner_bar.rb', line 24 def success(new_template = false) spinner.update(template: new_template) if new_template spinner.success end |