NAME

Indent - Class for indent handling.

SYNOPSIS

use Indent;
my $indent = Indent->new(%parameters);
$indent->add([$cur_indent]);
$indent->get;
$indent->remove([$cur_indent]);
$indent->reset([$reset_value]);

METHODS

new($option => $value)

This is a class method, the constructor for Indent. Options are passed as keyword value pairs. Recognized options are:

  • indent

    Default indent.
    Default value is ''.
  • next_indent

    Next indent. Adding to internal indent variable after every add method 
    calling.
    Default value is "\t" (tabelator).
add([$cur_indent])
Method for adding $cur_indent, if defined, or 'next_indent'.
get()
Get actual indent string.
remove([$cur_indent])
Method for removing $cur_indent, if defined, or 'next_indent'. Only if 
is removable.
reset([$reset_value])
Resets internal indent string to $reset_value or ''.

ERRORS

new():
        'next_indent' parameter must be defined.
        'next_indent' parameter must be a string.
        'indent' parameter must be defined.
        'indent' parameter must be a string.
        From Class::Utils::set_params():
                Unknown parameter '%s'.

remove():
        Cannot remove indent '$indent'.

EXAMPLE

# Pragmas.
use strict;
use warnings;

# Modules.
use Indent;

# Indent object.
my $indent = Indent->new(

       # Begin indent.
       'indent' => '->',

       # Next indent.
       'next_indent' => "->"
);

# Print example.
print $indent->get;
print "Example\n";

# Add indent and print ok.
$indent->add;
print $indent->get;
print "Ok\n";

# Remove indent and print nex example.
$indent->remove;
print $indent->get;
print "Example2\n";

# Reset.
$indent->reset;

# Output: 
# ->Example
# ->->Ok
# ->Example2

DEPENDENCIES

Class::Utils, Error::Pure, Readonly.

SEE ALSO

Indent::Block, Indent::Data, Indent::String, Indent::Utils, Indent::Word.

REPOSITORY

https://github.com/tupinek/Indent

AUTHOR

Michal Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

BSD licence.

VERSION

0.03