| 1 | #----------------------------------------------------------------- | ||||||||||||||
| 2 | # OWL::Data::Integer | ||||||||||||||
| 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: Integer.pm,v 1.3 2010-01-07 21:46:39 ubuntu Exp $ | ||||||||||||||
| 8 | #----------------------------------------------------------------- | ||||||||||||||
| 9 | |||||||||||||||
| 10 | package OWL::Data::Integer; | ||||||||||||||
| 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.3 $ =~ /: (\d+)\.(\d+)/; | |||||||||||||
| 17 | |||||||||||||||
| 18 | =head1 NAME | ||||||||||||||
| 19 | |||||||||||||||
| 20 | OWL::Data::Integer - A primitive data type for integers | ||||||||||||||
| 21 | |||||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||||
| 23 | |||||||||||||||
| 24 | use OWL::Data::Integer; | ||||||||||||||
| 25 | |||||||||||||||
| 26 | # create an Integer with initial value of -15 | ||||||||||||||
| 27 | my $data = OWL::Data::Integer->new (value => -15); | ||||||||||||||
| 28 | |||||||||||||||
| 29 | # set/get the value of this data object | ||||||||||||||
| 30 | $data->value (79); | ||||||||||||||
| 31 | print $data->value(); | ||||||||||||||
| 32 | |||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||
| 34 | |||||||||||||||
| 35 | An object representing an Integer. | ||||||||||||||
| 36 | |||||||||||||||
| 37 | =head1 AUTHORS | ||||||||||||||
| 38 | |||||||||||||||
| 39 | Edward Kawas (edward.kawas [at] gmail [dot] com) | ||||||||||||||
| 40 | Martin Senger (martin.senger [at] gmail [dot] com) | ||||||||||||||
| 41 | |||||||||||||||
| 42 | =cut | ||||||||||||||
| 43 | |||||||||||||||
| 44 | #----------------------------------------------------------------- | ||||||||||||||
| 45 | # A list of allowed attribute names. See OWL::Base for details. | ||||||||||||||
| 46 | #----------------------------------------------------------------- | ||||||||||||||
| 47 | |||||||||||||||
| 48 | =head1 ACCESSIBLE ATTRIBUTES | ||||||||||||||
| 49 | |||||||||||||||
| 50 | Details are in L<OWL::Base>. Here just a list of them (additionally | ||||||||||||||
| 51 | to the attributes from the parent classes) | ||||||||||||||
| 52 | |||||||||||||||
| 53 | =over | ||||||||||||||
| 54 | |||||||||||||||
| 55 | =item B<value> | ||||||||||||||
| 56 | |||||||||||||||
| 57 | A value of this datatype. Must be an integer. | ||||||||||||||
| 58 | |||||||||||||||
| 59 | =back | ||||||||||||||
| 60 | |||||||||||||||
| 61 | =cut | ||||||||||||||
| 62 | |||||||||||||||
| 63 | { | ||||||||||||||
| 64 | 3 | my %_allowed = | |||||||||||||
| 65 | ( | ||||||||||||||
| 66 | value => {type => OWL::Base->INTEGER}, | ||||||||||||||
| 67 | ); | ||||||||||||||
| 68 | |||||||||||||||
| 69 | 0 | ▶ | sub _accessible { | ||||||||||||
|
Subroutine
_accessible: not called CC=2 SCAR=17.9
| |||||||||||||||
| 70 | 0 | my ($self, $attr) = @_; | |||||||||||||
| 71 | 0 | ▶ | exists $_allowed{$attr} or $self->SUPER::_accessible ($attr); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 72 | } | ||||||||||||||
| 73 | 0 | ▶ | sub _attr_prop { | ||||||||||||
|
Subroutine
_attr_prop: not called CC=3 SCAR=24.8
| |||||||||||||||
| 74 | 0 | my ($self, $attr_name, $prop_name) = @_; | |||||||||||||
| 75 | 0 | my $attr = $_allowed {$attr_name}; | |||||||||||||
| 76 | 0 | ▶ | return ref ($attr) ? $attr->{$prop_name} : $attr if $attr; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 77 | 0 | return $self->SUPER::_attr_prop ($attr_name, $prop_name); | |||||||||||||
| 78 | } | ||||||||||||||
| 79 | } | ||||||||||||||
| 80 | |||||||||||||||
| 81 | #----------------------------------------------------------------- | ||||||||||||||
| 82 | # init | ||||||||||||||
| 83 | #----------------------------------------------------------------- | ||||||||||||||
| 84 | 3 | ▶ | sub init { | ||||||||||||
|
Subroutine
init: not called CC=1 SCAR=3.5
Pod
documented
| |||||||||||||||
| 85 | 0 | my ($self) = shift; | |||||||||||||
| 86 | 0 | $self->SUPER::init(); | |||||||||||||
| 87 | 0 | $self->primitive ('yes'); | |||||||||||||
| 88 | } | ||||||||||||||
| 89 | |||||||||||||||
| 90 | 3 | 1; | |||||||||||||
| 91 | __END__ | ||||||||||||||