Class: Planter::ProgressBar

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

Overview

Builds progress bars for seed runs.

Defined Under Namespace

Classes: NullProgressBar

Constant Summary collapse

FORMAT =

The format string used by visible progress bars.

Returns:

  • (String)
"%t |%B| %p%% %c/%C"

Class Method Summary collapse

Class Method Details

.create(title:, total:, output: $stdout) ⇒ ProgressBar, NullProgressBar

Create a visible progress bar, or a null progress bar when disabled.

Parameters:

  • title (String)

    progress bar title

  • total (Integer)

    total number of records to seed

  • output (IO) (defaults to: $stdout)

    progress bar output stream

Returns:



32
33
34
35
36
37
38
39
40
41
# File 'lib/planter/progress_bar.rb', line 32

def self.create(title:, total:, output: $stdout)
  return NullProgressBar.new unless enabled?(total)

  ::ProgressBar.create(
    title: title,
    total: total,
    output: output,
    format: FORMAT
  )
end