Class: CLI::Mastermind::UserInterface::AsyncSpinners

Inherits:
UI::SpinGroup
  • Object
show all
Defined in:
lib/cli/mastermind/user_interface.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAsyncSpinners

Returns a new instance of AsyncSpinners.



147
148
149
150
# File 'lib/cli/mastermind/user_interface.rb', line 147

def initialize
  @results = {}
  super
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



145
146
147
# File 'lib/cli/mastermind/user_interface.rb', line 145

def results
  @results
end

Instance Method Details

#await(title) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/cli/mastermind/user_interface.rb', line 152

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