| 1 | package Digital; | ||||||||||
| 2 | 3 | our $AUTHORITY = 'cpan:GETTY'; | |||||||||
| 3 | # ABSTRACT: Handling conversion of digital values towards physical units | ||||||||||
| 4 | 3 | $Digital::VERSION = '0.003'; | |||||||||
| 5 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | ▶ | use Package::Stash; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use Module::Runtime qw( use_module ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 3 | our %inputs; | |||||||||
| 11 | |||||||||||
| 12 | 3 | ▶ | sub register_input { | ||||||||
|
Subroutine
register_input: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 13 | 3 | my ( undef, $input, $input_class ) = @_; | |||||||||
| 14 | 3 | ▶ | unless (defined $input_class) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 3 | $input_class = $input; | |||||||||
| 16 | 3 | $input = lc($input_class); | |||||||||
| 17 | 3 | $input =~ s!::!_!g; | |||||||||
| 18 | 3 | $input =~ s!^digitalx_!!g; | |||||||||
| 19 | } | ||||||||||
| 20 | 3 | $inputs{$input} = $input_class; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 2 | ▶ | sub input { | ||||||||
|
Subroutine
input: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 24 | 2 | my ( $class, $input, @args ) = @_; | |||||||||
| 25 | 2 | my $input_class = $inputs{$input}; | |||||||||
| 26 | 2 | return $input_class->input(@args); | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 3 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=4 SCAR=15.9
| |||||||||||
| 30 | 3 | my ( $class, @args ) = @_; | |||||||||
| 31 | 3 | my ( $caller ) = caller; | |||||||||
| 32 | 3 | my $stash = Package::Stash->new($caller); | |||||||||
| 33 | 3 | my @classes; | |||||||||
| 34 | 0 | ▶ | for (@args) { unless (/^-/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | push @classes, 'DigitalX::'.$_; | |||||||||
| 36 | } } | ||||||||||
| 37 | 3 | for (@classes) { | |||||||||
| 38 | 0 | use_module($_); | |||||||||
| 39 | } | ||||||||||
| 40 | 3 | ▶ | $stash->add_symbol('&input', sub { return $class->input(@_) }); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 3 | 1; | |||||||||
| 44 | |||||||||||
| 45 | __END__ | ||||||||||