File Coverage

blib/lib/XML/XBEL/Alias.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1 2     2   3768 use strict;
  2         5  
  2         116  
2             package XML::XBEL::Alias;
3              
4 2         691 use base qw (XML::XBEL::base
5             XML::XBEL::thingy
6 2     2   12 XML::XBEL::serialize);
  2         5  
7              
8             # $Id: Alias.pm,v 1.4 2004/06/23 06:23:57 asc Exp $
9              
10             =head1 NAME
11              
12             XML::XBEL::Alias - OOP for reading and writing XBEL aliases.
13              
14             =head1 SYNOPSIS
15              
16             use XML::XBEL::Alias;
17              
18             =head1 DESCRIPTION
19              
20             OOP for reading and writing XBEL aliases.
21              
22             =cut
23              
24             use XML::LibXML;
25              
26             =head1 PACKAGE METHODS
27              
28             =cut
29              
30             =head2 __PACKAGE__->new(\%args)
31              
32             Valid args are :
33              
34             =over 4
35              
36             =item * B
37              
38             String.
39              
40             =back
41              
42             Returns an I object.
43              
44             =cut
45              
46             sub new {
47             my $pkg = shift;
48             my $args = shift;
49              
50             my $root = XML::LibXML::Element->new("alias");
51             my $self = bless {'__root' => $root }, $pkg;
52              
53             foreach my $el ("ref") {
54              
55             if (! exists($args->{$el})) {
56             next;
57             }
58              
59             $self->$el($args->{$el});
60             }
61              
62             return $self;
63             }
64              
65             =head1 OBJECT METHODS
66              
67             =cut
68              
69             =head2 $obj->ref((XML::XBEL::Bookmark || $pointer_)
70              
71             Get/set the reference for an alias.
72              
73             Returns a string when called with no arguments;
74             otherwise returns true or false.
75              
76             =cut
77              
78             sub ref {
79             my $self = shift;
80             my $pointer = shift;
81              
82             if (ref($pointer) eq "XML::XBEL::Bookmark") {
83             return $self->_attribute("ref",$pointer->id());
84             }
85              
86             # It would be nice to return the actual
87             # XML::XBEL::Bookmark object instead of
88             # just a string...
89              
90             return $self->_attribute("ref",$pointer);
91             }
92              
93             =head2 $obj->delete()
94              
95             Delete an XBEL alias.
96              
97             =cut
98              
99             # Defined in XML::XBEL::thingy
100              
101             =head2 $obj->toString($format)
102              
103             =cut
104              
105             # Defined in XML::XBEL::serialize
106              
107             =head2 $obj->toFile($filename,$format)
108              
109             =cut
110              
111             # Defined in XML::XBEL::serialize
112              
113             =head2 $obj->toFH(\*$fh,$format)
114              
115             =cut
116              
117             # Defined in XML::XBEL::serialize
118              
119             =head1 VERSION
120              
121             $Revision: 1.4 $
122              
123             =head1 DATE
124              
125             $Date: 2004/06/23 06:23:57 $
126              
127             =head1 AUTHOR
128              
129             Aaron Straup Cope Eascope@cpan.orgE
130              
131             =head1 SEE ALSO
132              
133             L
134              
135             L
136              
137             L
138              
139             L
140              
141             =head1 LICENSE
142              
143             Copyright (c) 2004 Aaron Straup Cope. All rights reserved.
144              
145             This is free software, you may use it and distribute it under the
146             same terms as Perl itself.
147              
148             =cut
149              
150             return 1;