IO::Path::Parts Reference
IO::Path parts encapsulation
What it is #
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method new #
method new(\volume, \dirname, \basename)
Create a new IO::Path::Parts object with \volume, \dirname and \basename as respectively the volume, directory name and basename parts.
attribute volume #
Read-only. Returns the volume of the IO::Path::Parts object.
attribute dirname #
Read-only. Returns the directory name part of the IO::Path::Parts object.
attribute basename #
Read-only. Returns the basename part of the IO::Path::Parts object. Before Rakudo 2020.06 the .parts method of IO::Path returned a Map and the .split routine of the IO::Spec sub-classes returned a List of Pair. The IO::Path::Parts class maintains compatibility with these previous implementations by doing Positional,
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
1 no-output · 3 ok · 1 rakupp-differs
class IO::Path::Parts does Positional does Associative does Iterable { }Not executed: the documentation states no expected output for this example.
IO::Path::Parts.new('C:', '/some/dir', 'foo.txt').volume.say;
# OUTPUT: «C:»C:
Documentation, Rakudo and Raku++ all agree.
IO::Path::Parts.new('C:', '/some/dir', 'foo.txt').dirname.say;
# OUTPUT: «/some/dir»/some/dir
Documentation, Rakudo and Raku++ all agree.
IO::Path::Parts.new('C:', '/some/dir', 'foo.txt').basename.say;
# OUTPUT: «foo.txt»foo.txt
Documentation, Rakudo and Raku++ all agree.
my $parts = IO::Path::Parts.new('C:', '/some/dir', 'foo.txt');
say $parts<volume>; # OUTPUT: «C:»
say $parts[0]; # OUTPUT: «volume => C:»
say $parts[0].^name; # OUTPUT: «Pair»
.say for $parts[];
# OUTPUT: «volume => C:dirname => /some/dirbasename => foo.txt»C:
volume => C:
Pair
volume => C:
dirname => /some/dir
basename => foo.txt
C:
volume => C:
Pair
volume => C:
dirname => /some/dir
basename => foo.txt
C:
(Any)
Any
basename foo.txt
dirname /some/dir
volume C:
Raku++ disagrees with both the documentation and Rakudo — a defect.