NAME

Piper::Path - Simple path object for labeling locations in Piper pipelines

SYNOPSIS

use Piper::Path;

# grandparent/parent/child
my $path = Piper::Path->new(qw(
    grandparent parent child
));

# grandparent/parent/child/grandchild
$path->child('grandchild');

# (qw(grandparent parent child))
$path->split;

# child
$path->name;

# 'grandparent/parent/child'
$path->stringify;
"$path";

DESCRIPTION

Simple filesystem-like representation of a pipeline segment's placement in the pipeline, relative to containing segments.

CONSTRUCTOR

new(@path_segments)

Creates a Piper::Path object from the given path segments.

Segments may be single path elements (similar to a file name), joined path elements (with /), or Piper::Path objects.

The following examples create equivalent objects:

Piper::Path->new(qw(grandparent parent child));
Piper::Path->new(qw(grandparent/parent child));
Piper::Path->new(
    Piper::Path->new(qw(grandparent parent)),
    qw(child)
);

METHODS

child(@segments)

Returns a new Piper::Path object representing the appropriate child of $self.

$path                     # grampa/parent
$path->child(qw(child))   # grampa/parent/child

name

Returns the last segment of the path, similar to the basename of a filesystem path.

$path         # foo/bar/baz
$path->name   # baz

split

Returns an array of the path segments.

$path          # foo/bar/baz
$path->split   # qw(foo bar baz)

stringify

Returns a string representation of the path, which is simply a join of the path segments with /.

String context is overloaded to call this method. The following are equivalent:

$path->stringify
"$path"

SEE ALSO

Piper

VERSION

version 0.03

AUTHOR

Mary Ehlers <ehlers@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by Mary Ehlers.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004