Amazon/Property/Book.pm

filter: Statementstmt 100% 39 / 39 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 25.0% 1 / 4 totaltotal 92.8% 52 / 56 CC 4 SCAR 4.7
CC
4
Cov
98%
new
2.0
init_via_xmlref
2.0
as_string
2.0
CRAP 1.6
« Amazon/Result/Seller.pm ↑ Summary Amazon/Property/VideoGames.pm »
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
BranchTrueFalseTotal
if (exists $options{"xmlref"}) 153 0 153
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
BranchTrueFalseTotal
if (defined $ref->{"PublicationDate"}) 151 2 153
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
BranchTrueFalseTotal
defined $self->authors ? : 67 9 76
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__
« Amazon/Result/Seller.pm ↑ Summary Amazon/Property/VideoGames.pm »