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