Gnavi/SearchResult.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 48 CC 2 SCAR 11.5
CC
2
Cov
0%
list
6.0
parse
2.0
pager
2.0
CRAP 3.1
1 # $Id: /mirror/perl/WebService-Gnavi/trunk/lib/WebService/Gnavi/SearchResult.pm 7171 2007-05-11T09:10:30.913520Z daisuke $
2 #
3 # Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>
4  
5 package WebService::Gnavi::SearchResult;
6 use strict;
7 use warnings;
8 use Data::Page;
9  
10 sub parse
11 {
12 my $class = shift;
13 my $xml = shift;
14  
15 my $pager = Data::Page->new(
16 $xml->findvalue('/response/total_hit_count'),
17 $xml->findvalue('/response/hit_per_page'),
18 $xml->findvalue('/response/page_offset')
19 );
20  
21 my @list;
22 foreach my $entry ($xml->findnodes('/response/rest')) {
23 my %data = (
24 map { ($_ => $entry->findvalue($_)) }
25 qw(id update_date name name_kana latitude longitude category url url_mobile address tel fax opentime holiday budget equipment)
26 );
27  
28 $data{image_url} = {
29 map { ($_ => $entry->findvalue("image_url/$_")) }
30 qw(shop_image1 shop_image2 qrcode)
31 };
32  
33 $data{access} = {
34 map { ($_ => $entry->findvalue("access/$_")) }
35 qw(line statin station_exit walk note)
36 };
37  
38 $data{pr} = {
39 map { ($_ => $entry->findvalue("pr/$_")) }
40 qw(pr_short pr_long)
41 };
42  
43 $data{flags} = {
44 map { ($_ => $entry->findvalue("flags/$_")) }
45 qw(mobile_site mobile_coupon pc_coupon)
46 };
47  
48 $data{code} = {
49 map { ($_ => $entry->findvalue("code/$_")) }
50 qw(areacode areaname prefcode)
51 };
52  
53 push @list, \%data;
54 }
55  
56 bless {
57 pager => $pager,
58 list => \@list
59 }, $class;
60 }
61  
62 sub pager { shift->{pager} }
63 sub list { wantarray ? @{ $_[0]->{list} } : $_[0]->{list} }
64  
65 1;
66  
67 __END__