Top Level Namespace

Defined Under Namespace

Classes: Project, Status

Instance Method Summary collapse

Instance Method Details

#with_progress(message = nil, &work) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cli.rb', line 8

def with_progress(message = nil, &work)
  print "#{message}" if message
  finished = false
  progress_thread = Thread.new { until finished; print "."; $stdout.flush; sleep 0.5; end; }
  work_thread = Thread.new(binding()) do |b|
    work.call
    finished = true
  end
  work_thread.join
  progress_thread.join
  say "\nDone!"
end