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 17     17   182420 use strict;
  17         44  
  17         641  
4 17     17   89 use warnings;
  17         46  
  17         5462  
5              
6             our $VERSION = '2.21';
7              
8             #ABSTRACT: Link object for WWW::Mechanize
9              
10              
11             sub new {
12 220     220 1 785406 my $class = shift;
13              
14 220         219 my $self;
15              
16             # The order of the first four must stay as they are for
17             # compatibility with older code.
18 220 100       4729 if ( ref $_[0] eq 'HASH' ) {
19 218         259 $self = [ @{ $_[0] }{qw( url text name tag base attrs )} ];
  218         5030  
20             }
21             else {
22 2         7 $self = [@_];
23             }
24              
25 220         552 return bless $self, $class;
26             }
27              
28              
29 338     338 1 17457 sub url { return ( $_[0] )->[0]; }
30 420     420 1 1256 sub text { return ( $_[0] )->[1]; }
31 34     34 1 106 sub name { return ( $_[0] )->[2]; }
32 48     48 1 147 sub tag { return ( $_[0] )->[3]; }
33 57     57 1 124 sub base { return ( $_[0] )->[4]; }
34 28     28 1 113 sub attrs { return ( $_[0] )->[5]; }
35              
36              
37             sub URI {
38 55     55 1 554 my $self = shift;
39              
40 55         1685 require URI::URL;
41 55         16097 my $URI = URI::URL->new( $self->url, $self->base );
42              
43 55         20035 return $URI;
44             }
45              
46              
47             sub url_abs {
48 53     53 1 2779 my $self = shift;
49              
50 53         68 return $self->URI->abs;
51             }
52              
53              
54             1;
55              
56             __END__