Class: ProgressBar::Outputs::NonTty

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

Constant Summary collapse

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

Constants inherited from ProgressBar::Output

ProgressBar::Output::DEFAULT_OUTPUT_STREAM

Instance Attribute Summary collapse

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 Attribute Details

#last_update_lengthObject



14
15
16
# File 'lib/ruby-progressbar/outputs/non_tty.rb', line 14

def last_update_length
  @last_update_length ||= 0
end

Instance Method Details

#bar_update_stringObject



18
19
20
21
22
23
24
25
26
# File 'lib/ruby-progressbar/outputs/non_tty.rb', line 18

def bar_update_string
  formatted_string        = bar.to_s
  formatted_string        = formatted_string[0...-1] unless bar.finished?

  output_string           = formatted_string[last_update_length..-1]
  self.last_update_length = formatted_string.length

  output_string.to_s
end

#clearObject



8
9
10
11
12
# File 'lib/ruby-progressbar/outputs/non_tty.rb', line 8

def clear
  self.last_update_length = 0

  stream.print "\n"
end

#default_formatObject



28
29
30
# File 'lib/ruby-progressbar/outputs/non_tty.rb', line 28

def default_format
  DEFAULT_FORMAT_STRING
end

#eolObject



38
39
40
# File 'lib/ruby-progressbar/outputs/non_tty.rb', line 38

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

#refresh_with_format_changeObject



36
# File 'lib/ruby-progressbar/outputs/non_tty.rb', line 36

def refresh_with_format_change(*); end

#resolve_formatObject



32
33
34
# File 'lib/ruby-progressbar/outputs/non_tty.rb', line 32

def resolve_format(*)
  default_format
end