| 1 | ###################################################################### | ||||||||||
| 2 | package Net::Amazon::Property::Book; | ||||||||||
| 3 | ###################################################################### | ||||||||||
| 4 | 24 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 24 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 24 | ▶ | use base qw(Net::Amazon::Property); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 24 | __PACKAGE__->make_accessor($_) for qw(publisher binding isbn | |||||||||
| 9 | dewey_decimal numpages edition ean publication_date); | ||||||||||
| 10 | 24 | __PACKAGE__->make_array_accessor($_) for qw(authors); | |||||||||
| 11 | |||||||||||
| 12 | ################################################## | ||||||||||
| 13 | 153 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 14 | ################################################## | ||||||||||
| 15 | 153 | my($class, %options) = @_; | |||||||||
| 16 | |||||||||||
| 17 | 153 | my $self = $class->SUPER::new(%options); | |||||||||
| 18 | 153 | bless $self, $class; # Bless into this class | |||||||||
| 19 | |||||||||||
| 20 | 153 | ▶ | if(exists $options{xmlref}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 153 | $self->init_via_xmlref($options{xmlref}); | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 153 | return $self; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | ################################################## | ||||||||||
| 28 | 153 | ▶ | sub init_via_xmlref { | ||||||||
|
Subroutine
init_via_xmlref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 29 | ################################################## | ||||||||||
| 30 | 153 | my($self, $xmlref) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 153 | $self->SUPER::init_via_xmlref($xmlref); | |||||||||
| 33 | |||||||||||
| 34 | 153 | my $ref = $xmlref->{ItemAttributes}; | |||||||||
| 35 | |||||||||||
| 36 | 153 | $self->authors($ref->{Author}); | |||||||||
| 37 | 153 | $self->binding($ref->{Binding}); | |||||||||
| 38 | 153 | $self->dewey_decimal($ref->{DeweyDecimalNumber}); | |||||||||
| 39 | 153 | $self->numpages($ref->{NumberOfPages}); | |||||||||
| 40 | 153 | $self->publisher($ref->{Publisher}); | |||||||||
| 41 | 153 | $self->isbn($ref->{ISBN}); | |||||||||
| 42 | 153 | $self->edition($ref->{Edition}); | |||||||||
| 43 | 153 | $self->ean($ref->{EAN}); | |||||||||
| 44 | |||||||||||
| 45 | 153 | my $year = 0; | |||||||||
| 46 | 153 | ▶ | if (defined $ref->{PublicationDate}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 151 | $year = (split(/\-/, $ref->{PublicationDate}))[0]; | |||||||||
| 48 | } | ||||||||||
| 49 | 153 | $self->year($year); | |||||||||
| 50 | |||||||||||
| 51 | 153 | $self->publication_date($ref->{PublicationDate}); | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | ################################################## | ||||||||||
| 55 | 4 | ▶ | sub author { | ||||||||
|
Subroutine
author: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 56 | ################################################## | ||||||||||
| 57 | 4 | my($self, $nameref) = @_; | |||||||||
| 58 | |||||||||||
| 59 | # Only return the first author | ||||||||||
| 60 | 4 | return ($self->authors($nameref))[0]; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | ################################################## | ||||||||||
| 64 | 76 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 65 | ################################################## | ||||||||||
| 66 | 76 | my($self) = @_; | |||||||||
| 67 | |||||||||||
| 68 | 76 | ▶ | my @a = (defined $self->authors) ? $self->authors : qw(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | |||||||||||
| 70 | 76 | return join('/', @a) . ", " . | |||||||||
| 71 | '"' . $self->title . '"' . ", " . | ||||||||||
| 72 | $self->year . ", " . | ||||||||||
| 73 | $self->_best_effort_price() . ", " . | ||||||||||
| 74 | $self->ASIN; | ||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 24 | 1; | |||||||||
| 78 | |||||||||||
| 79 | __END__ | ||||||||||