RDDL/Resource.pm

filter: Statementstmt 100% 25 / 25 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 17 / 17 Podpod 6.6% 1 / 15 totaltotal 72.5% 45 / 62 CC 2 SCAR 1.1
CC
2
Cov
93%
new
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« RDDL/Driver.pm ↑ Summary
1  
2 ###
3 # XML::RDDL::Resource - RDDL Resource Interface
4 # Robin Berjon <robin@knowscape.com>
5 # 17/10/2001 - v.0.01
6 ###
7  
8 package XML::RDDL::Resource;
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶$VERSION = $XML::RDDL::VERSION || '0.01';
Condition50%1/2
$XML::RDDL::VERSION || '0.01'
l!l
02
MC/DC0%0/1
$XML::RDDL::VERSION || '0.01'
$XML::RDDL::VERSION
Truth table50%1/2
A
A= $XML::RDDL::VERSION
Aresult
11
00
13  
14  
15 #-------------------------------------------------------------------#
16 # constructor
17 #-------------------------------------------------------------------#
18 5 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
19 5 ▶ my $class = ref($_[0]) ? ref(shift) : shift;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 5 5
20 5 my %opt = @_;
21 5 return bless \%opt, $class;
22 }
23 #-------------------------------------------------------------------#
24  
25  
26 #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#
27 #`,`, Accessors `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,#
28 #```````````````````````````````````````````````````````````````````#
29  
30 #-------------------------------------------------------------------#
31 # get and set
32 #-------------------------------------------------------------------#
33 10 ▶sub get_id { return $_[0]->{id}; }
Subroutine get_id: called CC=1 SCAR=0.0
Pod undocumented
34 6 ▶sub get_base_uri { return $_[0]->{base_uri}; }
Subroutine get_base_uri: called CC=1 SCAR=0.0
Pod undocumented
35 6 ▶sub get_href { return $_[0]->{href}; }
Subroutine get_href: called CC=1 SCAR=0.0
Pod undocumented
36 9 ▶sub get_nature { return $_[0]->{nature}; }
Subroutine get_nature: called CC=1 SCAR=0.0
Pod undocumented
37 9 ▶sub get_purpose { return $_[0]->{purpose}; }
Subroutine get_purpose: called CC=1 SCAR=0.0
Pod undocumented
38 7 ▶sub get_title { return $_[0]->{title}; }
Subroutine get_title: called CC=1 SCAR=0.0
Pod undocumented
39 6 ▶sub get_lang { return $_[0]->{lang}; }
Subroutine get_lang: called CC=1 SCAR=0.0
Pod undocumented
40 1 ▶sub set_id { $_[0]->{id} = $_[1]; }
Subroutine set_id: called CC=1 SCAR=0.0
Pod undocumented
41 1 ▶sub set_base_uri { $_[0]->{base_uri} = $_[1]; }
Subroutine set_base_uri: called CC=1 SCAR=0.0
Pod undocumented
42 1 ▶sub set_href { $_[0]->{href} = $_[1]; }
Subroutine set_href: called CC=1 SCAR=0.0
Pod undocumented
43 1 ▶sub set_nature { $_[0]->{nature} = $_[1]; }
Subroutine set_nature: called CC=1 SCAR=0.0
Pod undocumented
44 1 ▶sub set_purpose { $_[0]->{purpose} = $_[1]; }
Subroutine set_purpose: called CC=1 SCAR=0.0
Pod undocumented
45 1 ▶sub set_title { $_[0]->{title} = $_[1]; }
Subroutine set_title: called CC=1 SCAR=0.0
Pod undocumented
46 1 ▶sub set_lang { $_[0]->{lang} = $_[1]; }
Subroutine set_lang: called CC=1 SCAR=0.0
Pod undocumented
47 #-------------------------------------------------------------------#
48  
49  
50 2 1;
51 #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#
52 #`,`, Documentation `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,#
53 #```````````````````````````````````````````````````````````````````#
54  
55 =pod
56  
57 =head1 NAME
58  
59 XML::RDDL::Resource - RDDL Resource Interface
60  
61 =head1 SYNOPSIS
62  
63 use XML::RDDL::Resource;
64 # create a new Resource
65 my $res = XML::RDDL::Resource->new(
66 id => $id,
67 base_uri => $xbase,
68 href => $href,
69 nature => $role,
70 purpose => $arcrole,
71 title => $title,
72 lang => $lang,
73 );
74 # manipulate it in various ways
75 $foo = $res->get_id;
76 $foo = $res->get_base_uri;
77 $foo = $res->get_href;
78 $foo = $res->get_nature;
79 $foo = $res->get_purpose;
80 $foo = $res->get_title;
81 $foo = $res->get_lang;
82  
83 $res->set_id('foo');
84 $res->set_base_uri('foo');
85 $res->set_href('foo');
86 $res->set_nature('foo');
87 $res->set_purpose('foo');
88 $res->set_title('foo');
89 $res->set_lang('foo');
90  
91 =head1 DESCRIPTION
92  
93 XML::RDDL::Resource is an interface to a single RDDL Resouce
94 description, as found inside an RDDL document.
95  
96 =head1 METHODS
97  
98 =over 4
99  
100 =item XML::RDDL::Resource->new(%options)
101  
102 Creates a new Resource instance. None of the following options are
103 mandatory, but it is recommended that all be set, and of course a
104 Resource that doesn't have a nature, purpose, and href is moderately
105 useful.
106  
107 - id
108 the ID of the Resource (ought to be unique)
109  
110 - base_uri
111 the current base URI of the Resource, based on which the href is
112 resolved. This doesn't have to be set by an xml:base attribute of
113 the rddl:resource element but can also be the base URI of the
114 document, or set by the last xml:base in scope.
115  
116 - href
117 the xlink:href of the Resource which points to the actual resource
118 entity.
119  
120 - nature
121 the nature of the Resource (xlink:role)
122  
123 - purpose
124 the purpose of the Resource (xlink:arcrole)
125  
126 - title
127 the title of the Resource (xlink:title)
128  
129 - lang
130 the lang of the Resource. This doesn't have to be set by an
131 xml:lang attribute of the rddl:resource element but can also be
132 set by the last xml:lang in scope.
133  
134 =item Accessors
135  
136 All the above options have corresponding get_* and set_* accessors.
137 The get_* only return the value, and the set_* modify it without
138 returning anything.
139  
140 =back
141  
142 =head1 TODO
143  
144 - it may be that more accessors are needed depending on how RDDL
145 evolves
146 - URI resolution helpers may be wanted
147  
148 =head1 AUTHOR
149  
150 Robin Berjon, robin@knowscape.com
151  
152 =head1 COPYRIGHT
153  
154 Copyright (c) 2001-2002 Robin Berjon. All rights reserved. This program is
155 free software; you can redistribute it and/or modify it under the same
156 terms as Perl itself.
157  
158 =head1 SEE ALSO
159  
160 http://www.rddl.org/, XML::RDDL
161  
162 =cut
« RDDL/Driver.pm ↑ Summary