Test::OnlySome::PathCapsule - yet another object-oriented path representation
See Test::OnlySome, with which this module is distributed.
use Test::OnlySome::PathCapsule; my $path = Test::OnlySome::PathCapsule->new('some/path') my $cwd = Test::OnlySome::PathCapsule->new() $path->up() # move to the parent dir, if any $path->down('foo') # move to dir 'foo'
Test::OnlySome::PathCapsule doesn't care whether the path actually exists on disk.
Create a new instance.
my $path = Test::OnlySome::PathCapsule->new([$pathname_string[, $is_dir = 0]])
If $pathname_string is given, the instance points at that path. Otherwise, the instance points at cwd. If $is_dir, $pathname_string points at a directory; otherwise, it points at a file.
$pathname_string
$is_dir
Return a clone of this instance. Useful if you want to start from one path and move to others. Usage is $instance-clone()>.
$instance-
Move up one directory, if that is possible. Returns the instance, so you can chain calls. Usage:
$path->up([$keep_filename=0])
If $keep_filename is truthy, keep the filename. Otherwise, clear it out, since moving into a different directory probably invalidates the name.
$keep_filename
Returns the instance.
$path->down($whither[, $keep_filename=0])
Get or set the filename. Usage:
$self->file([$new_filename])
If no argument is given, returns the current filename, or undef if the path is a directory. If an argument is given, marks the instance as not representing a dir, and returns the instance.
undef
Returns true if the instance represents a directory as opposed to a file.
Returns the absolute path to the file. Usage: $self-abs>.
$self-
Returns the relative path to the file from the current working directory. Usage: $self-rel>.
Returns the relative path to the file from the current working directory at the time the instance was created. Usage: $self-rel_orig>.
To install Test::OnlySome, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::OnlySome
CPAN shell
perl -MCPAN -e shell install Test::OnlySome
For more information on module installation, please visit the detailed CPAN module installation guide.