Class: HubMerge::Spinner
- Inherits:
-
Object
- Object
- HubMerge::Spinner
- Defined in:
- lib/hubmerge/spinner.rb
Instance Method Summary collapse
- #ensure_active_parent! ⇒ Object
-
#initialize ⇒ Spinner
constructor
A new instance of Spinner.
- #with_child(text) ⇒ Object
- #with_parent(text) ⇒ Object
- #with_spinner(text) ⇒ Object
Constructor Details
#initialize ⇒ Spinner
Returns a new instance of Spinner.
6 7 8 |
# File 'lib/hubmerge/spinner.rb', line 6 def initialize @active_parent_spinner = nil end |
Instance Method Details
#ensure_active_parent! ⇒ Object
37 38 39 40 41 |
# File 'lib/hubmerge/spinner.rb', line 37 def ensure_active_parent! unless !!@active_parent_spinner raise "#with_parent not called!" end end |
#with_child(text) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hubmerge/spinner.rb', line 25 def with_child(text) ensure_active_parent! spinner = @active_parent_spinner.register(text) spinner.auto_spin result = yield spinner.success result rescue SpinnerError => e spinner.error(e.to_s) end |
#with_parent(text) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/hubmerge/spinner.rb', line 18 def with_parent(text) @active_parent_spinner = TTY::Spinner::Multi.new(text) yield ensure @active_parent_spinner = nil end |
#with_spinner(text) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/hubmerge/spinner.rb', line 10 def with_spinner(text) spinner = TTY::Spinner.new(text) spinner.auto_spin yield ensure spinner.stop end |