NAME

Indent - Class for indent handling.

SYNOPSIS

use Indent;

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

METHODS

new

my $indent = Indent->new(%parameters);

Constructor.

Returns instance of object.

  • 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

$indent->add([$cur_indent]);

Method for adding $cur_indent, if defined, or 'next_indent'.

Returns undef.

get

my $string = $indent->get;

Get actual indent string.

Returns string.

remove

$indent->remove([$cur_indent]);

Method for removing $cur_indent, if defined, or 'next_indent'. Only if is removable.

Returns undef.

reset

$indent->reset([$reset_value]);

Resets internal indent string to $reset_value or ''.

Returns undef.

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

use strict;
use warnings;

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

Class for block indenting.

Indent::Data

Class for data indenting.

Indent::String

Class for text indenting.

Indent::Utils

Utilities for Indent classes.

Indent::Word

Class for word indenting.

REPOSITORY

https://github.com/michal-josef-spacek/Indent

AUTHOR

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

http://skim.cz

LICENSE AND COPYRIGHT

© 2005-2024 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.09