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