URI-PathAbstract
view release on metacpan or search on metacpan
lib/URI/PathAbstract.pm view on Meta::CPAN
Returns a L<URI::PathAbstract> object that is the absolute URI formed by combining $uri and <base>
If <base> is not given, then $uri->base is used as the base
If <base> is not given and $uri->base does not exist, then a clone of $uri is returned
See L<URI> and L<URI::WithBase> for more C<abs> information
=cut
sub abs {
my $self = shift;
my $class = ref $self;
my $base = shift || $self->base || return $self->clone;
return $class->new(uri => $self->uri->abs("$base", @_), base => $base);
}
=head2 $uri->rel
=head2 $uri->rel( [ <base> ] )
Returns a L<URI::PathAbstract> object that is the relative URI formed by comparing $uri and <base>
If <base> is not given, then $uri->base is used as the base
If <base> is not given and $uri->base does not exist, then a clone of $uri is returned
See L<URI> and L<URI::WithBase> for more C<rel> information
=cut
sub rel {
my $self = shift;
my $class = ref $self;
my $base = shift || $self->base || return $self->clone;
return $class->new(uri => $self->uri->rel("$base", @_), base => $base);
}
{
=head2 URI
See L<URI> for more information
=head2 ->scheme
=head2 ->fragment
=head2 ->as_string
=head2 ->canonical
=head2 ->eq
=head2 ->authority
=head2 ->query
=head2 ->query_form
=head2 ->query_keywords
=head2 ->userinfo
=head2 ->host
=head2 ->port
=head2 ->host_port
=head2 ->default_port
=cut
no strict 'refs';
for my $method (grep { ! /^\s*#/ } split m/\n/, <<_END_) {
scheme
fragment
as_string
canonical
eq
authority
query
query_form
query_keywords
userinfo
host
port
host_port
default_port
_END_
*$method = sub {
my $self = shift;
return $self->{uri}->$method(@_);
}
}
#=head2 abs
#Returns a L<URI::PathAbstract> object
#=head2 rel
#Returns a L<URI::PathAbstract> object
#=cut
=head2 ->opaque
=head2 ->path_query
=head2 ->path_segments
=head2 Path::Abstract
See L<Path::Abstract> for more information
=head2 ->child
=head2 ->parent
=cut
for my $method (grep { ! /^\s*#/ } split m/\n/, <<_END_) {
child
parent
_END_
*$method = sub {
my $self = shift;
my $path = $self->{path}->$method(@_);
my $clone = $self->clone;
$clone->path($path);
return $clone;
}
}
=head2 ->up
=head2 ->pop
=head2 ->down
=head2 ->push
=head2 ->to_tree
( run in 0.399 second using v1.01-cache-2.11-cpan-96521ef73a4 )