Skip to content

Commit

Permalink
fixed perlcritic carping
Browse files Browse the repository at this point in the history
  • Loading branch information
periapt committed Sep 30, 2009
1 parent e0f0b1e commit 7affa8f
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions lib/Geo/Google/MapObject.pm
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,31 @@ sub new {
croak "maptype $args{maptype} not recognized" unless exists $MAPTYPE{$args{maptype}};
}
if (exists $args{size}) {
my $size = $args{size};
my ($width, $height);
if (ref($args{size}) eq "HASH") {
$width = $size->{width} || croak "no width";
$height = $size->{height} || croak "no height";
}
elsif($size =~ /^(\d{1,3})x(\d{1,3})$/) {
$width = $1;
$height = $2;
}
else {
croak "cannot recognize size";
}
croak "width should be no more than 640" unless ($width > 0 && $width <= 640);
croak "height should be no more than 640" unless ($height > 0 && $height <= 640);
my ($width, $height) = _parse_size($args{size});
$args{size} = {width=>$width,height=>$height};
}
return bless \%args, $class;
}

sub _parse_size {
my $size = shift;
my ($width, $height);
if (ref($size) eq "HASH") {
$width = $size->{width} || croak "no width";
$height = $size->{height} || croak "no height";
}
elsif($size =~ /^(\d{1,3})x(\d{1,3})$/) {
$width = $1;
$height = $2;
}
else {
croak "cannot recognize size";
}
croak "width should be no more than 640" unless ($width > 0 && $width <= 640);
croak "height should be no more than 640" unless ($height > 0 && $height <= 640);
return ($width, $height);
}

=head2 static_map_url
Returns a URL suitable for use as a fallback inside a noscript element.
Expand Down

0 comments on commit 7affa8f

Please sign in to comment.