File Coverage

blib/lib/WML/Deck.pm
Criterion Covered Total %
statement 15 38 39.4
branch 0 2 0.0
condition n/a
subroutine 4 11 36.3
pod 3 4 75.0
total 22 55 40.0


line stmt bran cond sub pod time code
1             package WML::Deck;
2              
3 1     1   1698 use strict;
  1         2  
  1         64  
4 1     1   5 use vars qw($VERSION);
  1         3  
  1         59  
5 1     1   7 use WML::Card;
  1         2  
  1         2227  
6              
7             $VERSION = '0.01';
8              
9              
10             sub new{
11 1     1 1 90 my $pkg = shift;
12 1         4 my @card = @_;
13 1         5 my $self = bless {
14             '_template' => undef,
15             '_card' => undef,
16             }, $pkg;
17 1         2 push @{$self->{'_card'}}, @card;
  1         11  
18 1         3 return $self;
19             };
20              
21              
22             sub _contenttype{
23 0     0     my $self = shift;
24 0           return "Content-type: text/vnd.wap.wml \n\n";
25             }
26              
27             sub cache{
28 0     0 1   my $self = shift;
29 0           $self->{'cache'} = shift;
30             }
31              
32             sub _cache{
33 0     0     my $self= shift;
34 0 0         return if !defined $self->{'cache'};
35 0           return << "EOF";
36            
37            
38            
39             EOF
40             }
41              
42              
43             sub _header{
44 0     0     my $self = shift;
45             return << 'EOF'
46            
47            
48              
49            
50             EOF
51 0           }
52              
53             sub template{
54 0     0 0   my $self = shift;
55 0           my ($type, $label , $href, $target) = @_;
56 0           $self->{'_wml'} .= << "EOF";
57            
65             EOF
66             }
67              
68             sub _footer{
69 0     0     my $self = shift;
70 0           return << 'EOF';
71            
72             EOF
73             }
74              
75              
76              
77             sub return_cgi{
78 0     0 1   my $self =shift;
79 0           print $self->_contenttype;
80 0           print $self->_header;
81 0           print $self->_cache;
82 0           print $self->{'_template'};
83 0           for (@{$self->{'_card'}}) {
  0            
84 0           $_->print;
85             }
86 0           print $self->_footer;
87             }
88              
89             =head1 NAME
90              
91             WML::Deck - Perl extension for builiding WML Decks.
92              
93             =head1 SYNOPSIS
94              
95             use WML::Card;
96              
97             use WML::Deck;
98              
99             my @cards;
100              
101             my $options= [
102             ['Option 1', 'http://...'],
103             ['Option 2', 'http://...'],
104              
105             ];
106              
107             my $c = WML::Card->guess('index','Wap Site');
108             $c->link_list('indice', undef, 0, $options, $options);
109             push @cards, $c;
110              
111             # Build the deck
112             my $wml = WML::Deck->new(@cards);
113             $wml->return_cgi;
114              
115             =head1 DESCRIPTION
116              
117             This perl library simplifies the creation of WML decks on the fly. In combination with
118             WML::Card it provides functionality to build WML code for cards and decks.
119              
120             =head2 Methods
121              
122             =over 4
123              
124             =item $wml = WML::Deck->new(@cards);
125              
126             This class method constructs a new WML::Deck object. The first argument is an array
127             of WML::Card objects.
128              
129             =item $wml->cache($n);
130              
131             This class methos specifies the max-age argument for Cache-Control
132              
133             =item $wml->return_cgi;
134              
135             This method prints wml code and HTTP headers for the deck.
136              
137             =head1 AUTHOR
138              
139             Mariana Alvaro mariana@alvaro.com.ar
140              
141             Copyright 2000 Mariana Alvaro. All rights reserved.
142             This library is free software; you can redistribute it and/or
143             modify it under the same terms as Perl itself.
144              
145             =head1 SEE ALSO
146              
147             WML::Card
148              
149             =cut
150              
151              
152              
153             1;