Top Level Namespace

Defined Under Namespace

Classes: Project, Status

Instance Method Summary collapse

Instance Method Details

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



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

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