ASP-NextLink
view release on metacpan or search on metacpan
NextLink.pm view on Meta::CPAN
=head1 USE
=head2 require ASP::NextLink;
=head1 METHOD REFERENCE
=head2 new( linkfile )
The new() class method accepts a virtual or relative path.
(Paths handed to new() are run through the $Server->MapPath() method.)
new() returns a reference to an ASP::NextLink object.
my $linkfile = "/links.txt";
my $nl = ASP::NextLink->new( $linkfile );
From now we will refer to the object returned by new() as $nl.
=cut
=head2 GetListCount()
Returns the number of links (lines containing tab-separated fields)
in link file.
my $count = $nl->GetListCount();
=cut
sub GetListCount {
my $self = shift;
die "Cannot call object method on class" unless ref $self;
$self->{_count};
}
=head2 GetListIndex()
Index of the current page in the link file.
=cut
sub GetListIndex {
my $self = shift;
die "Cannot call object method on class" unless ref $self;
$self->{_url}{$ENV{SCRIPT_FILENAME}}
or die "Current page not found in $self->{_file}";
}
=head2 GetPreviousURL()
URL of the previous page in the link file.
=cut
sub GetPreviousURL {
my $self = shift;
die "Cannot call object method on class" unless ref $self;
my $idx = $self->GetListIndex - 1;
exists( $self->{_idx}{$idx} )
? $self->{_idx}{$idx}[0] : undef;
}
=head2 GetPreviousDescription()
Description of the previous page in the link file.
=cut
sub GetPreviousDescription {
my $self = shift;
die "Cannot call object method on class" unless ref $self;
my $idx = $self->GetListIndex - 1;
exists( $self->{_idx}{$idx} )
? $self->{_idx}{$idx}[1] : undef;
}
=head2 GetNextURL()
URL of the next page in the link file.
=cut
sub GetNextURL {
my $self = shift;
die "Cannot call object method on class" unless ref $self;
my $idx = $self->GetListIndex + 1;
exists( $self->{_idx}{$idx} )
? $self->{_idx}{$idx}[1] : undef;
}
=head2 GetNextDescription()
Description of the next page in the link file.
=cut
sub GetNextDescription {
my $self = shift;
die "Cannot call object method on class" unless ref $self;
my $idx = $self->GetListIndex + 1;
exists( $self->{_idx}{$idx} )
? $self->{_idx}{$idx}[1] : undef;
}
=head2 GetNthURL( n )
URL of the nth page in the link file.
NOTE: Index is 1-based, NOT zero-based.
=cut
sub GetNthURL {
my $self = shift;
die "Cannot call object method on class" unless ref $self;
my $idx = shift;
$self->{_idx}{$idx}[0];
}
=head2 GetNthDescription( n )
Description of the nth page in the link file.
NOTE: Index is 1-based, NOT zero-based.
=cut
sub GetNthDescription {
my $self = shift;
die "Cannot call object method on class" unless ref $self;
my $idx = shift;
$self->{_idx}{$idx}[1];
}
=head1 AUTHOR
Tim Hammerquist E<lt>F<cafall@voffice.net>E<gt>
=head1 HISTORY
=over 4
=item Version 0.11
First functional release
=back
=head1 SEE ALSO
ASP(3)
=cut
1;
__END__
( run in 0.933 second using v1.01-cache-2.11-cpan-d80b1682f3f )