| 1 | package WWW::Marvel::Entity::Character; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use base qw/ Class::Accessor /; | ||
| 5 | __PACKAGE__->follow_best_practice; | ||
| 6 | __PACKAGE__->mk_ro_accessors(qw/ id comics description events modified name resourceURI series stories thumbnail urls /); | ||
| 7 | |||
| 8 | my %IMAGE_VARIANTS = ( | ||
| 9 | 'portrait_small' => '50x75px', | ||
| 10 | 'portrait_medium' => '100x150px', | ||
| 11 | 'portrait_xlarge' => '150x225px', | ||
| 12 | 'portrait_fantastic' => '168x252px', | ||
| 13 | 'portrait_uncanny' => '300x450px', | ||
| 14 | 'portrait_incredible' => '216x324px', | ||
| 15 | |||
| 16 | 'standard_small' => '65x45px', | ||
| 17 | 'standard_medium' => '100x100px', | ||
| 18 | 'standard_large' => '140x140px', | ||
| 19 | 'standard_xlarge' => '200x200px', | ||
| 20 | 'standard_fantastic' => '250x250px', | ||
| 21 | 'standard_amazing' => '180x180px', | ||
| 22 | |||
| 23 | 'landscape_small' => '120x90px', | ||
| 24 | 'landscape_medium' => '175x130px', | ||
| 25 | 'landscape_large' => '190x140px', | ||
| 26 | 'landscape_xlarge' => '270x200px', | ||
| 27 | 'landscape_amazing' => '250x156px', | ||
| 28 | 'landscape_incredible' => '464x261px', | ||
| 29 | ); | ||
| 30 | |||
| 31 | sub get_picture { | ||
| 32 | my ($self, $variant) = @_; | ||
| 33 | my $th = $self->get_thumbnail; | ||
| 34 | my $path = $th->{path}; | ||
| 35 | return if !defined $path; | ||
| 36 | $path .= "/$variant" if $variant && exists $IMAGE_VARIANTS{$variant}; | ||
| 37 | sprintf("%s.%s", $path, $th->{extension}); | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; | ||
| 41 |