Class: TTY::ProgressBar::Configuration
- Inherits:
-
Object
- Object
- TTY::ProgressBar::Configuration
- Includes:
- Formats
- Defined in:
- lib/tty/progressbar/configuration.rb
Constant Summary
Constants included from Formats
Instance Attribute Summary collapse
-
#bar_format ⇒ Object
The preconfigured bar format name, defaults to :classic.
-
#clear ⇒ Object
Whether or not to clear the progress line, defaults to false.
-
#clear_head ⇒ Object
Whether or not to replace head character with complete, defaults to false.
-
#complete ⇒ Object
The complete character in progress animation.
-
#frequency ⇒ Object
The frequency with which to display a progress bar per second.
-
#head ⇒ Object
The head character, defaults to complete.
-
#hide_cursor ⇒ Object
Whether or not to hide the cursor, defaults to false.
-
#incomplete ⇒ Object
The incomplete character in progress animation.
-
#inset ⇒ Object
private
The amount of indentation before a progress animation.
-
#interval ⇒ Object
The time interval for sampling of speed measurement, defaults to 1 second.
-
#output ⇒ Object
The object that responds to print call, defaults to stderr.
-
#total ⇒ Object
The total number of steps to completion.
-
#unknown ⇒ Object
The unknown character for indeterminate progress animation.
-
#width ⇒ Object
The maximum width for the progress bar except all formatting tokens.
Instance Method Summary collapse
-
#initialize(options) ⇒ Configuration
constructor
A new instance of Configuration.
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() self.total = [:total] if [:total] @width = .fetch(:width) { total } @bar_format = .fetch(:bar_format, :classic) self.incomplete = .fetch(:incomplete) { fetch_char(@bar_format, :incomplete) } self.complete = .fetch(:complete) { fetch_char(@bar_format, :complete) } self.unknown = .fetch(:unknown) { fetch_char(@bar_format, :unknown) } @head = .fetch(:head) { @complete || "=" } @clear_head = .fetch(:clear_head, false) @hide_cursor = .fetch(:hide_cursor, false) @clear = .fetch(:clear, false) @output = .fetch(:output) { $stderr } @frequency = .fetch(:frequency, 0) # 0Hz @interval = .fetch(:interval, 1) # 1 sec @inset = .fetch(:inset, 0) end |
Instance Attribute Details
#bar_format ⇒ Object
The preconfigured bar format name, defaults to :classic
40 41 42 |
# File 'lib/tty/progressbar/configuration.rb', line 40 def @bar_format end |
#clear ⇒ Object
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_head ⇒ Object
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 |
#complete ⇒ Object
The complete character in progress animation
20 21 22 |
# File 'lib/tty/progressbar/configuration.rb', line 20 def complete @complete end |
#frequency ⇒ Object
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 |
#head ⇒ Object
The head character, defaults to complete
28 29 30 |
# File 'lib/tty/progressbar/configuration.rb', line 28 def head @head end |
#hide_cursor ⇒ Object
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 |
#incomplete ⇒ Object
The incomplete character in progress animation
24 25 26 |
# File 'lib/tty/progressbar/configuration.rb', line 24 def incomplete @incomplete end |
#inset ⇒ Object
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 |
#interval ⇒ Object
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 |
#output ⇒ Object
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 |
#total ⇒ Object
The total number of steps to completion
12 13 14 |
# File 'lib/tty/progressbar/configuration.rb', line 12 def total @total end |
#unknown ⇒ Object
The unknown character for indeterminate progress animation
32 33 34 |
# File 'lib/tty/progressbar/configuration.rb', line 32 def unknown @unknown end |
#width ⇒ Object
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 |