File Coverage

blib/lib/Tree/XPathEngine/Variable.pm
Criterion Covered Total %
statement 3 18 16.6
branch n/a
condition n/a
subroutine 1 7 14.2
pod 6 6 100.0
total 10 31 32.2


line stmt bran cond sub pod time code
1             # $Id: /tree-xpathengine/trunk/lib/Tree/XPathEngine/Variable.pm 17 2006-02-12T08:00:01.814064Z mrodrigu $
2              
3             package Tree::XPathEngine::Variable;
4 5     5   29 use strict;
  5         9  
  5         1278  
5              
6             # This class does NOT contain 1 instance of a variable
7             # see the Tree::XPathEngine class for the instances
8             # This class simply holds the name of the var
9              
10             sub new {
11 0     0 1   my $class = shift;
12 0           my ($pp, $name) = @_;
13 0           bless { name => $name, path_parser => $pp }, $class;
14             }
15              
16             sub as_string {
17 0     0 1   my $self = shift;
18 0           '\$' . $self->{name};
19             }
20              
21             sub as_xml {
22 0     0 1   my $self = shift;
23 0           return "" . $self->{name} . "\n";
24             }
25              
26             sub xpath_get_value {
27 0     0 1   my $self = shift;
28 0           $self->{path_parser}->get_var($self->{name});
29             }
30              
31             sub xpath_set_value {
32 0     0 1   my $self = shift;
33 0           my ($val) = @_;
34 0           $self->{path_parser}->set_var($self->{name}, $val);
35             }
36              
37             sub evaluate {
38 0     0 1   my $self = shift;
39 0           my $val = $self->xpath_get_value;
40 0           return $val;
41             }
42              
43             1;
44              
45             __END__