File Coverage

blib/lib/WWW/Mechanize/Link.pm
Criterion Covered Total %
statement 25 25 100.0
branch 2 2 100.0
condition n/a
subroutine 11 11 100.0
pod 9 9 100.0
total 47 47 100.0


line stmt bran cond sub pod time code
1             package WWW::Mechanize::Link;
2              
3 16     16   272207 use strict;
  16         39  
  16         723  
4 16     16   95 use warnings;
  16         112  
  16         7307  
5              
6             our $VERSION = '2.20';
7              
8             #ABSTRACT: Link object for WWW::Mechanize
9              
10              
11             sub new {
12 211     211 1 815265 my $class = shift;
13              
14 211         4981 my $self;
15              
16             # The order of the first four must stay as they are for
17             # compatibility with older code.
18 211 100       5502 if ( ref $_[0] eq 'HASH' ) {
19 209         6075 $self = [ @{ $_[0] }{qw( url text name tag base attrs )} ];
  209         698  
20             }
21             else {
22 2         7 $self = [@_];
23             }
24              
25 211         7807 return bless $self, $class;
26             }
27              
28              
29 329     329 1 25922 sub url { return ( $_[0] )->[0]; }
30 411     411 1 2315 sub text { return ( $_[0] )->[1]; }
31 34     34 1 214 sub name { return ( $_[0] )->[2]; }
32 48     48 1 285 sub tag { return ( $_[0] )->[3]; }
33 57     57 1 294 sub base { return ( $_[0] )->[4]; }
34 28     28 1 250 sub attrs { return ( $_[0] )->[5]; }
35              
36              
37             sub URI {
38 55     55 1 1225 my $self = shift;
39              
40 55         2041 require URI::URL;
41 55         18782 my $URI = URI::URL->new( $self->url, $self->base );
42              
43 55         28057 return $URI;
44             }
45              
46              
47             sub url_abs {
48 53     53 1 3657 my $self = shift;
49              
50 53         127 return $self->URI->abs;
51             }
52              
53              
54             1;
55              
56             __END__