| 1 | package SemanticWeb::OAI::ORE::Agent; | ||||||||||||||||||||||||||||
| 2 | #$Id: Agent.pm,v 1.4 2010-12-06 14:44:15 simeon Exp $ | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | SemanticWeb::OAI::ORE::Agent - Module to represent http://purl.org/dc/terms/Agent | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 SYNPOSIS | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | my $agent=SemanticWeb::OAI::ORE::Agent->new; | ||||||||||||||||||||||||||||
| 11 | $agent->name("A Person"); | ||||||||||||||||||||||||||||
| 12 | $agent->mbox("person\@example.org"); | ||||||||||||||||||||||||||||
| 13 | print "Agent = ".$agent->name." <".$agent->mbox.">\n"; | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Within OAI-ORE an agent, typically but not necessarily a person, | ||||||||||||||||||||||||||||
| 18 | may have a name, an email address and a URI. | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 9 | ▶ | use Class::Accessor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 9 | ▶ | use base qw(Class::Accessor); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 9 | SemanticWeb::OAI::ORE::Agent->mk_accessors(qw(uri name mbox)); | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 METHODS | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head2 Creator | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head3 new() | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | Create SemanticWeb::OAI::ORE::Agent, may set uri, name and mbox via | ||||||||||||||||||||||||||||
| 37 | hash arguments. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =cut | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 2 | my $class=shift; | |||||||||||||||||||||||||||
| 43 | 2 | my $self={@_}; | |||||||||||||||||||||||||||
| 44 | 2 | ▶ | bless $self, (ref($class) || $class); | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 45 | 2 | return($self); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head2 Accessors | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head3 uri | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | URI of the Agent. This may be a blank node id. Use instead | ||||||||||||||||||||||||||||
| 53 | L<real_uri> if you want only globally meaningful URI. | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head3 real_uri | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | Wrapper around L<uri> which returns either a globally meaningful | ||||||||||||||||||||||||||||
| 58 | URI or undef if not set or a blank node. Cannot be used to set | ||||||||||||||||||||||||||||
| 59 | L<uriXX>. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | ▶ | sub real_uri { | ||||||||||||||||||||||||||
|
Subroutine
real_uri: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 1 | my $self=shift; | |||||||||||||||||||||||||||
| 65 | 1 | my $uri=$self->uri(@_); | |||||||||||||||||||||||||||
| 66 | 1 | ▶ | return( $uri && $uri!~/^_/ ? $uri : undef ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$uri and not $uri =~ /^_/
MC/DC0%0/2
$uri and not $uri =~ /^_/
$uri
not $uri =~ /^_/
Truth table33%1/3
A and not(B)
A= $uriB= not $uri =~ /^_/
| |||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head3 name | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | Accessor for foaf:name of this Agent | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head3 mbox | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | Accessor for foaf:mbox of this Agent | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 9 | 1; | |||||||||||||||||||||||||||