| 1 | package DerivedUnit; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use unitConverter; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use unit; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | # heritage | ||||||||||||||||||||
| 10 | 1 | ▶ | use base qw( Unit ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 9 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
| |||||||||||||||||||||
| 13 | 9 | my $class = shift; | |||||||||||||||||||
| 14 | 9 | my @definition = @_; | |||||||||||||||||||
| 15 | 9 | ▶ | $class = ref($class) || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 16 | 9 | my $this = $class->SUPER::new(); | |||||||||||||||||||
| 17 | 9 | bless($this, $class); | |||||||||||||||||||
| 18 | 9 | $this->{DEFINITION} = [@definition]; | |||||||||||||||||||
| 19 | 9 | return $this; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 10 | ▶ | sub definition { | ||||||||||||||||||
|
Subroutine
definition: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 10 | my $this = shift; | |||||||||||||||||||
| 24 | 10 | my @titi = $this->{DEFINITION}; | |||||||||||||||||||
| 25 | 10 | return @{$this->{DEFINITION}}; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 10 | ▶ | sub toBase { | ||||||||||||||||||
|
Subroutine
toBase: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 29 | 10 | my $this = shift; | |||||||||||||||||||
| 30 | 10 | my $transform = UnitConverter->identity; | |||||||||||||||||||
| 31 | 10 | my @def = $this->definition; | |||||||||||||||||||
| 32 | 10 | for (@def) { | |||||||||||||||||||
| 33 | 18 | $transform = $_->dim->toBase->linearPow($_->power)->concatenate($transform); | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | 10 | return $transform; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =head1 NAME | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | DerivedUnit - representation of an unit defined as a factor of powers of units | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =head1 DESCRIPTION | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | This module maps a conceptual class that represents an unit defined as a factor of powers of units. | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =head1 AUTHOR | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | Samuel Andres | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head1 LICENSE | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | UnLicense | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||
| 55 | 1 | 1; | |||||||||||||||||||