View Source PacmanProgressBar (pacman_progress_bar v0.2.1)

This module creates a progress bar based on Arch Linux's pacman package manager

Link to this section Summary

Functions

Returns the progress bar in the form of a string

Writes the progress bar to the terminal using IO.write/2. Calling this function again will overwrite the last progress bar. If all tasks are completed it will automatically print a newline character

Link to this section Functions

Link to this function

raw(total_tasks, completed_tasks, opts \\ [])

View Source
@spec raw(number(), number(), keyword()) :: nonempty_binary()

Returns the progress bar in the form of a string

Use PacmanProgressBar.render/2 if you automatically want to write this string to the terminal

options

Options

  • :use_color (boolean) - set to true if you want the pacman character to be yellow
  • :bar_size (integer) - the amount of characters between the square brackets. A correct value can be calculated by changing n in 2 + (n * 3)

examples

Examples

iex> PacmanProgressBar.raw(30, 7)
#=> "[------c o  o  o  o  o  o  o  ]  23%"
Link to this function

render(total_tasks, completed_tasks, opts \\ [])

View Source
@spec render(number(), number(), keyword()) :: nil | :ok

Writes the progress bar to the terminal using IO.write/2. Calling this function again will overwrite the last progress bar. If all tasks are completed it will automatically print a newline character

Use PacmanProgressBar.raw/2 to get the progress bar in the form of a string

options

Options

  • :use_color (boolean) - set to true if you want the pacman character to be yellow
  • :bar_size (integer) - the amount of characters between the square brackets. A correct value can be calculated by changing n in 2 + (n * 3)

examples

Examples

iex> PacmanProgressBar.render(30, 7)
#=> [------c o  o  o  o  o  o  o  ]  23%

iex> PacmanProgressBar.render(30, 7)
     PacmanProgressBar.render(30, 10)
#=> [---------C o  o  o  o  o  o  ]  33%