class UI::Simple::Task

Public Class Methods

new(title, &callback) click to toggle source
# File lib/kuber_kit/ui/simple.rb, line 7
def initialize(title, &callback)
  @title = title
  @callback = callback
end

Public Instance Methods

execute() click to toggle source
# File lib/kuber_kit/ui/simple.rb, line 20
def execute
  if @thread
    raise "Already started execution of task '#{title}'"
  end

  @thread = Thread.new do
    Thread.current.abort_on_exception = true
    Thread.current.report_on_exception = false
    print_started
    @callback.call(self)
    print_finished
  end
end
print_finished() click to toggle source
print_started() click to toggle source
update_title(title) click to toggle source
# File lib/kuber_kit/ui/simple.rb, line 41
def update_title(title)
  @title = title
end
wait() click to toggle source
# File lib/kuber_kit/ui/simple.rb, line 34
def wait
  if !@thread
    raise "Task '#{title}' not started"
  end
  @thread.join
end