lib/OWL/Data/OWL/ObjectProperty.pm

filter: Statementstmt 70.8% 34 / 48 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 10 / 14 Podpod 50.0% 1 / 2 totaltotal 62.5% 45 / 72 CC 5 SCAR 13.8
CC
5
Cov
61%
_attr_prop
12.0
_accessible
6.0
get_statement
6.0
CRAP 4.0
« lib/OWL/Data/OWL/Class.pm ↑ Summary lib/OWL/Data/Def/DatatypeProperty.pm »
1 #-----------------------------------------------------------------
2 # OWL::Data::OWL::ObjectProperty
3 # Author: Edward Kawas <edward.kawas@gmail.com>,
4 # For copyright and disclaimer see below.
5 #
6 # $Id: ObjectProperty.pm,v 1.2 2009-10-27 16:24:10 ubuntu Exp $
7 #-----------------------------------------------------------------
8 package OWL::Data::OWL::ObjectProperty;
9 2 ▶use base ("OWL::Base");
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11
12 # imports
13 2 ▶use RDF::Core::Resource;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use RDF::Core::Statement;
Subroutine BEGIN: called CC=1 SCAR=0.0
15
16 2 ▶use OWL::RDF::Predicates::DC_PROTEGE;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use OWL::RDF::Predicates::OMG_LSID;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use OWL::RDF::Predicates::OWL;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use OWL::RDF::Predicates::RDF;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use OWL::RDF::Predicates::RDFS;
Subroutine BEGIN: called CC=1 SCAR=0.0
21
22 # add versioning to this module
23 2 ▶use vars qw /$VERSION/;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /: (\d+)\.(\d+)/;
25
26 =head1 NAME
27
28 OWL::Data::OWL::ObjectProperty
29
30 =head1 SYNOPSIS
31
32 use OWL::Data::OWL::ObjectProperty;
33
34 # create an owl ObjectProperty
35 my $data = OWL::Data::OWL::ObjectProperty->new ();
36
37
38 =head1 DESCRIPTION
39
40 An object representing an OWL ObjectProperty
41
42 =head1 AUTHORS
43
44 Edward Kawas (edward.kawas [at] gmail [dot] com)
45
46 =cut
47
48 #-----------------------------------------------------------------
49 # A list of allowed attribute names. See OWL::Base for details.
50 #-----------------------------------------------------------------
51
52 =head1 ACCESSIBLE ATTRIBUTES
53
54 Details are in L<OWL::Base>. Here just a list of them:
55
56 =over
57
58 =item B<value> - the subject, a URI, that this object property is a predicate for
59
60 =item B<range> - the range of this object property
61
62 =item B<domain> - the domain of this object property
63
64 =item B<uri> - the uri of this object property
65
66 =back
67
68 =cut
69
70 {
71 2 my %_allowed = (
72 value => { type => OWL::Base->STRING },
73 range => { type => OWL::Base->STRING },
74 domain => { type => OWL::Base->STRING },
75 uri => { type => OWL::Base->STRING },
76 #statements => {type => 'RDF::Core::Statement', is_array => 1}
77 );
78
79 0 ▶ sub _accessible {
Subroutine _accessible: not called CC=2 SCAR=17.9
80 0 my ( $self, $attr ) = @_;
81 0 ▶ exists $_allowed{$attr} or $self->SUPER::_accessible($attr);
Branch: 1 branch
BranchTrueFalseTotal
exists $_allowed{$attr} or $self->SUPER::_accessible($attr) 0 0 0
82 }
83
84 0 ▶ sub _attr_prop {
Subroutine _attr_prop: not called CC=3 SCAR=24.8
85 0 my ( $self, $attr_name, $prop_name ) = @_;
86 0 my $attr = $_allowed{$attr_name};
87 0 ▶ return ref($attr) ? $attr->{$prop_name} : $attr if $attr;
Branch: 2 branches
BranchTrueFalseTotal
if $attr 0 0 0
ref $attr ? : 0 0 0
88 0 return $self->SUPER::_attr_prop( $attr_name, $prop_name );
89 }
90 }
91
92 #-----------------------------------------------------------------
93
94 =head1 SUBROUTINES
95
96 =cut
97
98 #-----------------------------------------------------------------
99 # init
100 #-----------------------------------------------------------------
101 2 ▶sub init {
Subroutine init: not called CC=1 SCAR=2.6
Pod documented
102 0 my ($self) = shift;
103 0 $self->SUPER::init();
104 }
105
106 0 ▶sub get_statement {
Subroutine get_statement: not called CC=2 SCAR=17.9
Pod undocumented
107 0 my $self = shift;
108 0 ▶ $self->throw('Range not set for Object property!') unless defined $self->range;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->range 0 0 0
109
110 0 my $subject = new RDF::Core::Resource( $self->value );
111 0 my $predicate = $subject->new( OWL::RDF::Predicates::RDF->type );
112 0 my $object = new RDF::Core::Resource( $self->range );
113 0 return new RDF::Core::Statement($subject, $predicate, $object)
114 }
115 2 1;
116 __END__
« lib/OWL/Data/OWL/Class.pm ↑ Summary lib/OWL/Data/Def/DatatypeProperty.pm »