File Coverage

blib/lib/WebService/Recruit/HotPepper/Base.pm
Criterion Covered Total %
statement 13 42 30.9
branch 0 24 0.0
condition 0 8 0.0
subroutine 5 12 41.6
pod 8 8 100.0
total 26 94 27.6


line stmt bran cond sub pod time code
1             package WebService::Recruit::HotPepper::Base;
2 3     3   22 use strict;
  3         8  
  3         104  
3 3     3   15 use base qw( XML::OverHTTP );
  3         7  
  3         3018  
4 3     3   199932 use vars qw( $VERSION );
  3         7  
  3         163  
5             $VERSION = '0.02';
6              
7 3     3   8371 use Class::Accessor::Children::Fast;
  3         1793  
  3         1112  
8              
9 2     2 1 856 sub default_param { {}; }
10 0     0 1   sub notnull_param { [qw( key )]; }
11 0     0 1   sub attr_prefix { ''; }
12              
13             sub is_error {
14 0     0 1   my $self = shift;
15 0           my $tree = $self->tree();
16 0           my $mess;
17 0 0         if ( ref $tree ){
18 0 0         my $error = $tree->{Error} or return;
19 0 0         $mess = $error->{Message} or return;
20             }else{
21 0 0         my $xml = $self->xml() or return;
22 0 0         return unless ( $xml =~ m{\s*$} );
23 0           $mess = ( $xml =~ m{([^<>]*?)}s )[0];
24             }
25 0           $mess;
26             }
27             sub total_entries {
28 0     0 1   my $self = shift;
29 0 0         my $root = $self->root() or return;
30 0 0         $root->{NumberOfResults} || 0;
31             }
32             sub entries_per_page {
33 0     0 1   my $self = shift;
34 0 0         my $root = $self->root() or return;
35 0 0         $root->{DisplayPerPage} || 10;
36             }
37             sub current_page {
38 0     0 1   my $self = shift;
39 0 0         my $root = $self->root() or return;
40 0 0         my $epp = $self->entries_per_page() or return;
41 0 0         int(($root->{DisplayFrom}-1) / $epp)+1 || 1;
42             }
43             sub page_param {
44 0     0 1   my $self = shift;
45 0   0       my $page = shift || $self->current_page();
46 0   0       my $size = shift || $self->entries_per_page();
47 0   0       my $hash = shift || {};
48 0           $hash->{Start} = ($page-1) * $size + 1;
49 0           $hash->{Count} = $size;
50 0           $hash;
51             }
52              
53             =head1 NAME
54              
55             WebService::Recruit::HotPepper::Base - Base class for HotPepper Web Service Beta
56              
57             =head1 DESCRIPTION
58              
59             This is a base class for the HotPepper Web Service I.
60             L uses this internally.
61              
62             =head1 SEE ALSO
63              
64             L, L
65              
66             =head1 AUTHOR
67              
68             Toshimasa Ishibashi L
69              
70             This module is unofficial and released by the author in person.
71              
72             =head1 THANKS TO
73              
74             Yusuke Kawasaki L
75              
76             For creating/preparing all the base modules and stuff.
77              
78             =head1 COPYRIGHT AND LICENSE
79              
80             Copyright (c) 2007 Toshimasa Ishibashi. All rights reserved.
81             This program is free software; you can redistribute it and/or
82             modify it under the same terms as Perl itself.
83              
84             =cut
85              
86             1;