File Coverage

blib/lib/WWW/WolframAlpha/Info.pm
Criterion Covered Total %
statement 15 38 39.4
branch 0 6 0.0
condition 0 6 0.0
subroutine 5 9 55.5
pod 0 4 0.0
total 20 63 31.7


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