Class: CLIProgressBar::ProgressBar

Inherits:
Object
  • Object
show all
Defined in:
lib/cli_progress_bar/progress_bar.rb

Overview

Parent progress bar class to be inherited from only.

Direct Known Subclasses

ItemProgressBar, PercentProgressBar

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(of: "", log_at: LOG_AT_TEN_PERCENTS, bar_length: BAR_LENGTH, line_char: LINE_CHAR, prefix: "", suffix: "", stream: STD_OUT) ⇒ ProgressBar



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cli_progress_bar/progress_bar.rb', line 6

def initialize(
  of: "", log_at: LOG_AT_TEN_PERCENTS, bar_length: BAR_LENGTH,
  line_char: LINE_CHAR, prefix: "", suffix: "", stream: STD_OUT
)
  raise "bar_length: must be positive and even" unless bar_length.positive? && bar_length.even?
  raise "stream: must respond to #puts" unless stream.respond_to?(:puts)

  @progress = 0
  @of = of.to_s
  @log_at = log_at
  @bar_length = bar_length
  @line_char = line_char
  @prefix = prefix
  @suffix = suffix
  @stream = stream
end

Instance Attribute Details

#progressObject (readonly)

Returns the value of attribute progress.



4
5
6
# File 'lib/cli_progress_bar/progress_bar.rb', line 4

def progress
  @progress
end