Class: TTY::ProgressBar::Configuration

Inherits:
Object
  • Object
show all
Includes:
Formats
Defined in:
lib/tty/progressbar/configuration.rb

Constant Summary

Constants included from Formats

Formats::FORMATS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Configuration

Returns a new instance of Configuration.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/tty/progressbar/configuration.rb', line 66

def initialize(options)
  self.total   = options[:total] if options[:total]
  @width       = options.fetch(:width) { total }
  @bar_format  = options.fetch(:bar_format, :classic)
  self.incomplete = options.fetch(:incomplete) { fetch_char(@bar_format, :incomplete) }
  self.complete = options.fetch(:complete) { fetch_char(@bar_format, :complete) }
  self.unknown = options.fetch(:unknown) { fetch_char(@bar_format, :unknown) }
  @head        = options.fetch(:head) { @complete || "=" }
  @clear_head  = options.fetch(:clear_head, false)
  @hide_cursor = options.fetch(:hide_cursor, false)
  @clear       = options.fetch(:clear, false)
  @output      = options.fetch(:output) { $stderr }
  @frequency   = options.fetch(:frequency, 0) # 0Hz
  @interval    = options.fetch(:interval, 1) # 1 sec
  @inset       = options.fetch(:inset, 0)
end

Instance Attribute Details

#bar_formatObject

The preconfigured bar format name, defaults to :classic



40
41
42
# File 'lib/tty/progressbar/configuration.rb', line 40

def bar_format
  @bar_format
end

#clearObject

Whether or not to clear the progress line, defaults to false



60
61
62
# File 'lib/tty/progressbar/configuration.rb', line 60

def clear
  @clear
end

#clear_headObject

Whether or not to replace head character with complete, defaults to false



64
65
66
# File 'lib/tty/progressbar/configuration.rb', line 64

def clear_head
  @clear_head
end

#completeObject

The complete character in progress animation



20
21
22
# File 'lib/tty/progressbar/configuration.rb', line 20

def complete
  @complete
end

#frequencyObject

The frequency with which to display a progress bar per second



48
49
50
# File 'lib/tty/progressbar/configuration.rb', line 48

def frequency
  @frequency
end

#headObject

The head character, defaults to complete



28
29
30
# File 'lib/tty/progressbar/configuration.rb', line 28

def head
  @head
end

#hide_cursorObject

Whether or not to hide the cursor, defaults to false



56
57
58
# File 'lib/tty/progressbar/configuration.rb', line 56

def hide_cursor
  @hide_cursor
end

#incompleteObject

The incomplete character in progress animation



24
25
26
# File 'lib/tty/progressbar/configuration.rb', line 24

def incomplete
  @incomplete
end

#insetObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The amount of indentation before a progress animation



36
37
38
# File 'lib/tty/progressbar/configuration.rb', line 36

def inset
  @inset
end

#intervalObject

The time interval for sampling of speed measurement, defaults to 1 second



52
53
54
# File 'lib/tty/progressbar/configuration.rb', line 52

def interval
  @interval
end

#outputObject

The object that responds to print call, defaults to stderr



44
45
46
# File 'lib/tty/progressbar/configuration.rb', line 44

def output
  @output
end

#totalObject

The total number of steps to completion



12
13
14
# File 'lib/tty/progressbar/configuration.rb', line 12

def total
  @total
end

#unknownObject

The unknown character for indeterminate progress animation



32
33
34
# File 'lib/tty/progressbar/configuration.rb', line 32

def unknown
  @unknown
end

#widthObject

The maximum width for the progress bar except all formatting tokens



16
17
18
# File 'lib/tty/progressbar/configuration.rb', line 16

def width
  @width
end