File Coverage

blib/lib/WWW/WolframAlpha/Subpod.pm
Criterion Covered Total %
statement 9 39 23.0
branch 0 14 0.0
condition 0 8 0.0
subroutine 3 10 30.0
pod 0 7 0.0
total 12 78 15.3


line stmt bran cond sub pod time code
1             package WWW::WolframAlpha::Subpod;
2              
3 1     1   17 use 5.008008;
  1         3  
  1         36  
4 1     1   4 use strict;
  1         2  
  1         72  
5 1     1   5 use warnings;
  1         2  
  1         503  
6              
7             require Exporter;
8              
9             our @ISA = qw(Exporter);
10              
11             # Items to export into callers namespace by default. Note: do not export
12             # names by default without a very good reason. Use EXPORT_OK instead.
13             # Do not simply export all your public functions/methods/constants.
14              
15             # This allows declaration use WWW::WolframAlpha ':all';
16             # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
17             # will save memory.
18             our %EXPORT_TAGS = ( 'all' => [ qw(
19             ) ] );
20              
21             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
22              
23             our @EXPORT = qw(
24             );
25              
26             our $VERSION = '1.0';
27              
28             sub new {
29 0     0 0   my $class = shift;
30 0           my $xmlo = shift;
31              
32 0           my $self = {};
33              
34 0           my ($title,$plaintext,$img,$minput,$moutput,$mathml);
35              
36 0 0         if ($xmlo) {
37 0           $title = $xmlo->{'title'};
38 0           $plaintext = $xmlo->{'plaintext'}; # could be 0
39 0   0       $img = $xmlo->{'img'} || undef;
40 0   0       $minput = $xmlo->{'minput'} || undef;
41 0   0       $moutput = $xmlo->{'moutput'} || undef;
42 0   0       $mathml = $xmlo->{'mathml'} || undef;
43              
44 0 0         $self->{'title'} = $title if defined $title;
45 0 0         $self->{'plaintext'} = $plaintext if defined $plaintext;
46 0 0         $self->{'minput'} = $minput if defined $minput;
47 0 0         $self->{'moutput'} = $moutput if defined $moutput;
48 0 0         $self->{'mathml'} = $mathml if defined $mathml;
49              
50 0 0         if (defined $img) {
51 0           my $html = '
52 0           foreach my $attr (keys %{$img}) {
  0            
53 0           $html .= ' ' . $attr . '=\'' . $img->{$attr} . '\'';
54             }
55 0           $html .= '/>';
56 0           $self->{'img'} = $html;
57             }
58             }
59              
60 0           return(bless($self, $class));
61             }
62              
63 0     0 0   sub title {shift->{'title'};}
64 0     0 0   sub plaintext {shift->{'plaintext'};}
65 0     0 0   sub img {shift->{'img'};}
66 0     0 0   sub minput {shift->{'minput'};}
67 0     0 0   sub moutput {shift->{'moutput'};}
68 0     0 0   sub mathml {shift->{'mathml'};}
69              
70              
71             # Preloaded methods go here.
72              
73             1;
74              
75              
76             =pod
77              
78             =head1 NAME
79              
80             WWW::WolframAlpha::Subpod
81              
82             =head1 VERSION
83              
84             version 1.10
85              
86             =head1 SYNOPSIS
87              
88             foreach my $subpod (@{$pod->subpods}) {
89             print " Subpod\n";
90             print ' plaintext: ', $subpod->plaintext, "\n" if $subpod->plaintext;
91             print ' title: ', $subpod->title, "\n" if $subpod->title;
92             print ' minput: ', $subpod->minput, "\n" if $subpod->minput;
93             print ' moutput: ', $subpod->moutput, "\n" if $subpod->moutput;
94             print ' mathml: ', $subpod->mathml, "\n" if $subpod->mathml;
95             print ' img: ', $subpod->img, "\n" if $subpod->img;
96             }
97              
98             =head1 DESCRIPTION
99              
100             =head2 ATTRIBUTES
101              
102             $subpod->plaintext
103              
104             $subpod->title
105              
106             $subpod->minput
107              
108             $subpod->moutput
109              
110             $subpod->mathml
111              
112             $sbupod->img
113              
114             =head2 EXPORT
115              
116             None by default.
117              
118             =head1 NAME
119              
120             WWW::WolframAlpha::Subpod - Perl objects accessed via $pod->subpods
121              
122             =head1 SEE ALSO
123              
124             L
125              
126             =head1 AUTHOR
127              
128             Gabriel Weinberg, Eyegg@alum.mit.eduE
129              
130             =head1 COPYRIGHT AND LICENSE
131              
132             Copyright (C) 2009 by Gabriel Weinberg
133              
134             This library is free software; you can redistribute it and/or modify
135             it under the same terms as Perl itself, either Perl version 5.8.8 or,
136             at your option, any later version of Perl 5 you may have available.
137              
138             =head1 AUTHOR
139              
140             Gabriel Weinberg
141              
142             =head1 COPYRIGHT AND LICENSE
143              
144             This software is copyright (c) 2009 by Gabriel Weinberg.
145              
146             This is free software; you can redistribute it and/or modify it under
147             the same terms as the Perl 5 programming language system itself.
148              
149             =cut
150              
151              
152             __END__