Class: Bosh::Cli::FileWithProgressBar

Inherits:
File
  • Object
show all
Defined in:
lib/cli/director.rb

Instance Method Summary collapse

Instance Method Details

#progress_barObject



597
598
599
600
601
602
603
604
# File 'lib/cli/director.rb', line 597

def progress_bar
  return @progress_bar if @progress_bar
  out = Bosh::Cli::Config.output || StringIO.new
  @progress_bar = ProgressBar.new(File.basename(self.path),
                                  File.size(self.path), out)
  @progress_bar.file_transfer_mode
  @progress_bar
end

#read(*args) ⇒ Object



614
615
616
617
618
619
620
621
622
623
624
# File 'lib/cli/director.rb', line 614

def read(*args)
  result = super(*args)

  if result && result.size > 0
    progress_bar.inc(result.size)
  else
    progress_bar.finish
  end

  result
end

#sizeObject



610
611
612
# File 'lib/cli/director.rb', line 610

def size
  File.size(self.path)
end

#stop_progress_barObject



606
607
608
# File 'lib/cli/director.rb', line 606

def stop_progress_bar
  progress_bar.halt unless progress_bar.finished?
end