Class: ProgressBar::Outputs::Tty

Inherits:
ProgressBar::Output show all
Defined in:
lib/ruby-progressbar/outputs/tty.rb

Constant Summary collapse

DEFAULT_FORMAT_STRING =
'%t: |%B|'.freeze

Constants inherited from ProgressBar::Output

ProgressBar::Output::DEFAULT_OUTPUT_STREAM

Instance Attribute Summary

Attributes inherited from ProgressBar::Output

#stream

Instance Method Summary collapse

Methods inherited from ProgressBar::Output

#clear_string, detect, #initialize, #length, #log, #refresh, #with_refresh

Constructor Details

This class inherits a constructor from ProgressBar::Output

Instance Method Details

#bar_update_stringObject



15
16
17
# File 'lib/ruby-progressbar/outputs/tty.rb', line 15

def bar_update_string
  bar.to_s
end

#clearObject



10
11
12
13
# File 'lib/ruby-progressbar/outputs/tty.rb', line 10

def clear
  stream.print clear_string
  stream.print "\r"
end

#default_formatObject



19
20
21
# File 'lib/ruby-progressbar/outputs/tty.rb', line 19

def default_format
  ENV['RUBY_PROGRESS_BAR_FORMAT'] || DEFAULT_FORMAT_STRING
end

#eolObject



27
28
29
# File 'lib/ruby-progressbar/outputs/tty.rb', line 27

def eol
  bar.stopped? ? "\n" : "\r"
end

#resolve_format(other_format) ⇒ Object



23
24
25
# File 'lib/ruby-progressbar/outputs/tty.rb', line 23

def resolve_format(other_format)
  other_format || default_format
end