lib/OWL/Data/Boolean.pm

filter: Statementstmt 84.6% 22 / 26 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 76.1% 32 / 42 CC 5 SCAR 10.2
CC
5
Cov
74%
_express_value
6.0
_attr_prop
3.5
_accessible
2.1
CRAP 2.8
« lib/OWL/Data/Def/ObjectProperty.pm ↑ Summary lib/OWL/Data/Def/OWLClass.pm »
1 #-----------------------------------------------------------------
2 # OWL::Data::Boolean
3 # Author: Edward Kawas <edward.kawas@gmail.com>,
4 # Martin Senger <martin.senger@gmail.com>
5 # For copyright and disclaimer see below.
6 #
7 # $Id: Boolean.pm,v 1.5 2010-01-07 21:44:17 ubuntu Exp $
8 #-----------------------------------------------------------------
9
10 package OWL::Data::Boolean;
11 3 ▶use base ("OWL::Data::Object");
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13
14 # add versioning to this module
15 3 ▶use vars qw /$VERSION/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 $VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /: (\d+)\.(\d+)/;
17
18 =head1 NAME
19
20 OWL::Data::Boolean - A primitive data type for booleans
21
22 =head1 SYNOPSIS
23
24 use OWL::Data::Boolean;
25
26 # create an owl Boolean with initial value of true
27 my $data = OWL::Data::Boolean->new ( value=>'true' );
28 my $data = OWL::Data::Boolean->new ('true');
29 my $data = OWL::Data::Boolean->new ();
30
31 # change the value to false
32 $data->value ('false');
33
34 # get the value
35 print $data->value;
36
37 =head1 DESCRIPTION
38
39 An object representing a Boolan.
40
41 =head1 AUTHORS
42
43 Edward Kawas (edward.kawas [at] gmail [dot] com)
44 Martin Senger (martin.senger [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 (additionally
55 to the attributes from the parent classes)
56
57 =over
58
59 =item B<value>
60
61 A value of this datatype. Must be a boolean (defaults to 1).
62
63 =back
64
65 =cut
66
67 {
68 3 my %_allowed =
69 (
70 value => {type => OWL::Base->BOOLEAN},
71 );
72
73 1 ▶ sub _accessible {
Subroutine _accessible: called CC=2 SCAR=7.2
74 1 my ($self, $attr) = @_;
75 1 ▶ exists $_allowed{$attr} or $self->SUPER::_accessible ($attr);
Branch: 1 branch
BranchTrueFalseTotal
exists $_allowed{$attr} or $self->SUPER::_accessible($attr) 1 0 1
76 }
77 4 ▶ sub _attr_prop {
Subroutine _attr_prop: called CC=3 SCAR=12.5
78 4 my ($self, $attr_name, $prop_name) = @_;
79 4 my $attr = $_allowed {$attr_name};
80 4 ▶ return ref ($attr) ? $attr->{$prop_name} : $attr if $attr;
Branch: 2 branches
BranchTrueFalseTotal
if $attr 4 0 4
ref $attr ? : 4 0 4
81 0 return $self->SUPER::_attr_prop ($attr_name, $prop_name);
82 }
83 }
84
85 #-----------------------------------------------------------------
86 # init
87 #-----------------------------------------------------------------
88 3 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod documented
89 2 my ($self) = shift;
90 2 $self->SUPER::init();
91 2 $self->primitive ('yes');
92 2 $self->value(1);
93 }
94
95 0 ▶sub _express_value {
Subroutine _express_value: not called CC=2 SCAR=17.9
96 0 shift;
97 0 my ($value) = shift;
98 0 ▶ $value ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
99 }
100
101
102 3 1;
103 __END__
« lib/OWL/Data/Def/ObjectProperty.pm ↑ Summary lib/OWL/Data/Def/OWLClass.pm »