| 1 | # ABSTRACT: Models a photo in the NewsReach API. | ||
| 2 | package WWW::NewsReach::Photo; | ||
| 3 | |||
| 4 | 3 | our $VERSION = '0.06'; | |
| 5 | |||
| 6 | 3 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 3 | ▶ | use WWW::NewsReach::Photo::Instance; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | has $_ => ( | ||
| 11 | is => 'ro', | ||
| 12 | isa => 'Str', | ||
| 13 | 3 | ) for qw( caption alt orientation ); | |
| 14 | |||
| 15 | 3 | has id => ( | |
| 16 | is => 'ro', | ||
| 17 | isa => 'Int', | ||
| 18 | ); | ||
| 19 | |||
| 20 | 3 | has instances => ( | |
| 21 | is => 'ro', | ||
| 22 | isa => 'ArrayRef[WWW::NewsReach::Photo::Instance]', | ||
| 23 | ); | ||
| 24 | |||
| 25 | |||
| 26 | 0 | ▶ | sub new_from_xml { |
|
Subroutine
new_from_xml: not called CC=3 SCAR=24.8
Pod
documented
| |||
| 27 | 0 | my $class = shift; | |
| 28 | 0 | my ( $xml ) = @_; | |
| 29 | |||
| 30 | 0 | my $self = {}; | |
| 31 | |||
| 32 | 0 | foreach (qw[id caption orientation]) { | |
| 33 | 0 | $self->{$_} = $xml->findnodes("//$_")->[0]->textContent; | |
| 34 | } | ||
| 35 | |||
| 36 | 0 | $self->{alt} = $xml->findnodes('//htmlAlt')->[0]->textContent; | |
| 37 | |||
| 38 | 0 | foreach my $instance ( $xml->findnodes("//instance") ) { | |
| 39 | 0 | my $photo = | |
| 40 | WWW::NewsReach::Photo::Instance->new_from_xml( $instance ); | ||
| 41 | 0 | push @{$self->{instances}}, $photo; | |
| 42 | } | ||
| 43 | 0 | return $class->new( $self ); | |
| 44 | } | ||
| 45 | |||
| 46 | 3 | 1; | |
| 47 | |||
| 48 | __END__ | ||