Class: CLI::Mastermind::UserInterface::AsyncSpinners
- Inherits:
-
UI::SpinGroup
- Object
- UI::SpinGroup
- CLI::Mastermind::UserInterface::AsyncSpinners
- Defined in:
- lib/cli/mastermind/user_interface.rb
Overview
Implementation of CLI::UI::SpinGroup with that keeps track of the results from individual spinners.
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#await(title) {|spinner| ... } ⇒ Object
Waits for a block to execute while displaying a spinner.
-
#initialize ⇒ AsyncSpinners
constructor
A new instance of AsyncSpinners.
Constructor Details
#initialize ⇒ AsyncSpinners
Returns a new instance of AsyncSpinners.
197 198 199 200 |
# File 'lib/cli/mastermind/user_interface.rb', line 197 def initialize @results = {} super end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
195 196 197 |
# File 'lib/cli/mastermind/user_interface.rb', line 195 def results @results end |
Instance Method Details
#await(title) {|spinner| ... } ⇒ Object
Waits for a block to execute while displaying a spinner.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/cli/mastermind/user_interface.rb', line 207 def await(title) @results[title] = nil add(title) do |spinner| catch(:success) do msg = catch(:fail) do @results[title] = yield spinner throw :success end puts msg CLI::UI::Spinner::TASK_FAILED end end end |