Andreas Hernitscheck > String-ProgressBar-0.03 > String::ProgressBar

Download:
String-ProgressBar-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

String::ProgressBar - Produces a simple progress bar

SYNOPSIS ^

   use String::ProgressBar;
   my $pr = String::ProgressBar->new( max => 30 );

   $pr->update( 10 ); # step 10 of 30
   $pr->write;

   # shows that:
   # [=======             ]  33% [10/30]

   # If you want to print it by yourself:

   use String::ProgressBar;
   my $pr = String::ProgressBar->new( max => 30 );

   print $pr->update( 10 )->string()."\r";

The progress bar has a fix matrix and look liket that:

 first          [====================] 100% [30/30]

DESCRIPTION ^

It is an OO class to produce a simple progress bar which can be used at a shell. It does not use curses and has no large dependencies.

REQUIRES ^

Carp

METHODS ^

new

 my $object = $this->new(max => $int);

Constructor

It can take several key value pairs (here you see also the default values):

               length          =>  20     # length of the bar
               border_left     =>  '['    # left bracked of the bar
               border_right    =>  ']',   # right bracked of the bar
               bar             =>  '=',   # used element of the bar
               show_rotation   =>  0,     # if it should show a rotating element
               show_percent    =>  1,     # show percent
               show_amount     =>  1,     # show value/max
               text            =>  '',    # text before text bar. If empty, starts on the very left end
               info            =>  '',    # text after the bar
               print_return    =>  0,     # whether it should return after last value with new line
               text_length     =>  14,    # length of the text before the bar

info

 my $object = $this->info($string);

updates info (after bar) with a new value and returns the object itself.

string

 my $string = $this->string();

returns the bar as simple string, so you may write it by yourself.

text

 my $object = $this->text($string);

updates text (before bar) with a new value and returns the object itself.

update

 $this->update();

updates the bar with a new value and returns the object itself.

write

 $this->write();

Writes the bar to STDOUT.

AUTHOR ^

Andreas Hernitscheck ahernit(AT)cpan.org

LICENSE ^

You can redistribute it and/or modify it under the conditions of LGPL.

syntax highlighting: