| 1 | package Math::Histogram; | ||||||||||
| 2 | 7 | ▶ | use 5.008001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 7 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 7 | ▶ | use JSON::XS (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 7 | our $VERSION = '1.03'; | |||||||||
| 9 | |||||||||||
| 10 | 7 | require XSLoader; | |||||||||
| 11 | 7 | XSLoader::load('Math::Histogram', $VERSION); | |||||||||
| 12 | |||||||||||
| 13 | 7 | require Math::Histogram::Axis; | |||||||||
| 14 | |||||||||||
| 15 | 7 | require Exporter; | |||||||||
| 16 | 7 | our @ISA = qw(Exporter); | |||||||||
| 17 | 7 | our @EXPORT_OK = qw( | |||||||||
| 18 | make_histogram | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 7 | our %EXPORT_TAGS = ( | |||||||||
| 22 | 'all' => \@EXPORT_OK, | ||||||||||
| 23 | ); | ||||||||||
| 24 | |||||||||||
| 25 | sub make_histogram { | ||||||||||
| 26 | 10 | ▶ | my @axises = map Math::Histogram::Axis->new(@$_), @_; | ||||||||
|
Subroutine
make_histogram: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 27 | 10 | return Math::Histogram->new(\@axises); | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | sub _from_hash { | ||||||||||
| 31 | 1 | ▶ | my ($class, $hashref) = @_; | ||||||||
|
Subroutine
_from_hash: called CC=3 SCAR=13.3
| |||||||||||
| 32 | 1 | my $axises_in = $hashref->{axises}; | |||||||||
| 33 | 1 | ▶ | if (not ref($axises_in) eq 'ARRAY') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 1 | croak("Need 'axises' hash element as an array reference"); | |||||||||
| 35 | } | ||||||||||
| 36 | 0 | my $axises = []; | |||||||||
| 37 | 0 | push @$axises, Math::Histogram::Axis->_from_hash($_) for @$axises_in; | |||||||||
| 38 | 0 | return $class->_from_hash_internal($hashref, $axises); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | sub serialize { | ||||||||||
| 42 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
serialize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 43 | 0 | my $hash = $self->_as_hash; | |||||||||
| 44 | 0 | return JSON::XS::encode_json($hash); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | sub deserialize { | ||||||||||
| 48 | 0 | ▶ | my $class = shift; | ||||||||
|
Subroutine
deserialize: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 49 | 0 | ▶ | my $hash = JSON::XS::decode_json(ref($_[0]) ? ${$_[0]} : $_[0]); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | return $class->_from_hash($hash); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 7 | 1; | |||||||||
| 54 | __END__ | ||||||||||