Class: Bosh::Cli::FileWithProgressBar
- Defined in:
- lib/cli/file_with_progress_bar.rb
Instance Method Summary collapse
- #file_name ⇒ Object
- #progress_bar ⇒ Object
- #read(*args) ⇒ Object
- #size ⇒ Object
- #size=(size) ⇒ Object
- #stop_progress_bar ⇒ Object
- #write(*args) ⇒ Object
Instance Method Details
#file_name ⇒ Object
13 14 15 |
# File 'lib/cli/file_with_progress_bar.rb', line 13 def file_name File.basename(self.path) end |
#progress_bar ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/cli/file_with_progress_bar.rb', line 5 def return @progress_bar if @progress_bar out = Bosh::Cli::Config.output || StringIO.new @progress_bar = ProgressBar.new(file_name, size, out) @progress_bar.file_transfer_mode @progress_bar end |
#read(*args) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cli/file_with_progress_bar.rb', line 29 def read(*args) result = super(*args) if result && result.size > 0 .inc(result.size) else .set(size) .finish end result end |
#size ⇒ Object
21 22 23 |
# File 'lib/cli/file_with_progress_bar.rb', line 21 def size @size || File.size(self.path) end |
#size=(size) ⇒ Object
25 26 27 |
# File 'lib/cli/file_with_progress_bar.rb', line 25 def size=(size) @size=size end |
#stop_progress_bar ⇒ Object
17 18 19 |
# File 'lib/cli/file_with_progress_bar.rb', line 17 def .halt unless .finished? end |
#write(*args) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cli/file_with_progress_bar.rb', line 42 def write(*args) count = super(*args) if count .inc(count) else .set(size) .finish end count end |