| 1 | ### Change History | ||||||||||||||||||||||||||||||||||
| 2 | # 1998-12-03 Created. -Simon | ||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||
| 4 | package Data::Quantity::Abstract::InstanceIndex; | ||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | 3 | require 5; | |||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | 3 | $VERSION = 0.001; | |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Data::Quantity::Number::Integer '-isasubclass'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Class::MakeMethods ( | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 3 | 'Standard::Inheritable:scalar' => 'instances', | |||||||||||||||||||||||||||||||||
| 16 | 3 | ); | |||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | # $flag = Data::Quantity::Abstract::InstanceIndex->is_valid_index($number); | ||||||||||||||||||||||||||||||||||
| 19 | # Is this value acceptable for this quantity. | ||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub is_valid_index { | ||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_index: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 21 | 0 | my $class_or_item = shift; | |||||||||||||||||||||||||||||||||
| 22 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $instances = $class_or_item->instances or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | return ( $value >= 0 and $value == int($value) and $value <= $#$instances ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$value >= 0 && $value == int $value && $value <= $instances->$#*
$value >= 0 and $value == int $value
MC/DC0%0/3
$value >= 0 && $value == int $value && $value <= $instances->$#*
$value >= 0
$value == int $value
$value <= $instances->$#*
Truth table0%0/4
A and B && C
A= $value >= 0B= $value == int $valueC= $value <= $instances->$#*
| |||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | # $flag = Data::Quantity::Abstract::InstanceIndex->is_index_value($number); | ||||||||||||||||||||||||||||||||||
| 29 | # Is this value acceptable, and *not blank or empty*, for this quantity. | ||||||||||||||||||||||||||||||||||
| 30 | 11 | ▶ | sub is_index_value { | ||||||||||||||||||||||||||||||||
|
Subroutine
is_index_value: called CC=4 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 31 | 11 | my $class_or_item = shift; | |||||||||||||||||||||||||||||||||
| 32 | 11 | my $value = shift; | |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | 11 | ▶ | my $instances = $class_or_item->instances or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 35 | 11 | ▶ | return ( $value > 0 and $value == int($value) and $value <= $#$instances ); | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
$value > 0 && $value == int $value && $value <= $instances->$#*
$value > 0 and $value == int $value
MC/DC0%0/3
$value > 0 && $value == int $value && $value <= $instances->$#*
$value > 0
$value == int $value
$value <= $instances->$#*
Truth table25%1/4
A and B && C
A= $value > 0B= $value == int $valueC= $value <= $instances->$#*
| |||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||
| 38 | # $definition = Data::Quantity::Abstract::InstanceIndex->instance($number); | ||||||||||||||||||||||||||||||||||
| 39 | 11 | ▶ | sub instance { | ||||||||||||||||||||||||||||||||
|
Subroutine
instance: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 40 | 11 | my $class_or_item = shift; | |||||||||||||||||||||||||||||||||
| 41 | 11 | my $value = shift; | |||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | 11 | ▶ | return unless $class_or_item->is_index_value($value); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 44 | 11 | return $class_or_item->instances->[ $value ]; | |||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | # $value = Data::Quantity::Abstract::InstanceIndex->readable_value($number) | ||||||||||||||||||||||||||||||||||
| 48 | # $value = Data::Quantity::Abstract::InstanceIndex->readable_value($number, $style) | ||||||||||||||||||||||||||||||||||
| 49 | 11 | ▶ | sub readable_value { | ||||||||||||||||||||||||||||||||
|
Subroutine
readable_value: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 50 | 11 | my $class_or_item = shift; | |||||||||||||||||||||||||||||||||
| 51 | 11 | my $value = shift; | |||||||||||||||||||||||||||||||||
| 52 | 11 | ▶ | my $style = shift || 'name'; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 'name'
MC/DC100%1/1
shift() || 'name'
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | 11 | ▶ | my $instance = $class_or_item->instance($value) or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | 11 | return $instance->{ $style }; | |||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | 3 | 1; | |||||||||||||||||||||||||||||||||