File Coverage

blib/lib/WWW/Patent/Page/Response.pm
Criterion Covered Total %
statement 38 40 95.0
branch 4 6 66.6
condition n/a
subroutine 11 11 100.0
pod n/a
total 53 57 92.9


line stmt bran cond sub pod time code
1              
2             package WWW::Patent::Page::Response
3             ; #modeled on LWP::UserAgent and HTTP::Response
4 5     5   35 use strict;
  5         14  
  5         216  
5 5     5   41 use warnings;
  5         12  
  5         258  
6 5     5   29 use diagnostics;
  5         12  
  5         45  
7 5     5   708 use Carp;
  5         10  
  5         391  
8              
9 5     5   6831 use subs qw( new get_parameter set_parameter content is_success message );
  5         161  
  5         31  
10             our ($VERSION);
11              
12             $VERSION = 0.021;
13              
14             sub new #_HTTP_Response
15             {
16 23     23   265 my ( $class, %patent_parameters_passed ) = @_;
17 23         370 my $self = {
18             'doc_id' => undef,
19             'doc_id_standardized' => undef, # US6123456 sparse
20             'doc_id_commified' => undef, # US6,123,456
21             'is_success' => undef,
22             'content' => undef,
23             'message' => undef,
24             'format' => undef,
25             'office' => undef,
26             'office_username' => undef,
27             'office_password' => undef,
28             'session_token' => undef,
29             'country' => undef,
30             'doc_type' => undef,
31             'number' => undef,
32             'kind' => undef,
33             'pages' => undef,
34             'page' => undef,
35             'version' => undef,
36             'comment' => undef,
37             'tempdir' => undef,
38              
39             };
40 23         131 for my $key ( keys %patent_parameters_passed ) {
41 391 50       861 if ( exists $self->{$key} ) {
42 391         813 $self->{$key} = $patent_parameters_passed{$key};
43             }
44             else {
45 0         0 carp "parameter '$key' not recognized-",
46             " value '$patent_parameters_passed{$key}'";
47             }
48             }
49 23         293 bless $self, $class;
50             }
51              
52             sub content {
53 10     10   36 my $self = shift;
54 10         125 return ($self->{'content'})
55             }
56             sub is_success {
57 9     9   71 my $self = shift;
58 9         47 return ($self->{'is_success'})
59             }
60             sub message {
61 17     17   23 my $self = shift;
62 17         108 return ($self->{'message'})
63             }
64              
65             sub get_parameter {
66 123     123   3767 my $self = shift;
67 123         156 my $parameter = shift;
68 123 100       301 if (defined($self->{$parameter})) {return $self->{$parameter}; }
  122         551  
  1         4  
69             else {return undef };
70             }
71              
72             sub set_parameter {
73 34     34   194 my $self = shift;
74 34         56 my $parameter = shift;
75 34         151 my $value = shift;
76 34 50       118 if (exists($self->{$parameter})) { $self->{$parameter} = $value; return (1);}
  34         115  
  34         92  
  0            
77             else {return undef };
78             }
79              
80             __END__