1 package WWW::Mechanize::Image;
9 WWW::Mechanize::Image - Image object for WWW::Mechanize
13 Image object to encapsulate all the stuff that Mech needs
19 Creates and returns a new C<WWW::Mechanize::Image> object.
21 my $image = WWW::Mechanize::Image->new( {
25 name => $name, # From the INPUT tag
26 height => $height, # optional
27 width => $width, # optional
28 alt => $alt, # optional
35 my $parms = shift || {};
37 my $self = bless {}, $class;
39 for my $parm ( qw( url base tag height width alt name ) ) {
40 # Check for what we passed in, not whether it's defined
41 $self->{$parm} = $parms->{$parm} if exists $parms->{$parm};
44 # url and tag are always required
45 for ( qw( url tag ) ) {
46 exists $self->{$_} or die "WWW::Mechanize::Image->new must have a $_ argument";
60 Base URL to which the links are relative.
64 Name for the field from the NAME attribute, if any.
68 Tag name (either "image" or "input")
70 =head2 $link->height()
80 ALT attribute from the source tag, if any.
84 sub url { return ($_[0])->{url}; }
85 sub base { return ($_[0])->{base}; }
86 sub name { return ($_[0])->{name}; }
87 sub tag { return ($_[0])->{tag}; }
88 sub height { return ($_[0])->{height}; }
89 sub width { return ($_[0])->{width}; }
90 sub alt { return ($_[0])->{alt}; }
94 Returns the URL as a L<URI::URL> object.
102 my $URI = URI::URL->new( $self->url, $self->base );
107 =head2 $link->url_abs()
109 Returns the URL as an absolute URL string.
116 return $self->URI->abs;
121 Copyright (c) 2004 Andy Lester. All rights reserved. This program is
122 free software; you can redistribute it and/or modify it under the same
123 terms as Perl itself.