File Coverage

blib/lib/Statistics/R/REXP/Double.pm
Criterion Covered Total %
statement 29 29 100.0
branch 7 8 87.5
condition 1 3 33.3
subroutine 9 9 100.0
pod 0 2 0.0
total 46 51 90.2


line stmt bran cond sub pod time code
1             package Statistics::R::REXP::Double;
2             # ABSTRACT: an R numeric vector
3             $Statistics::R::REXP::Double::VERSION = '1.0';
4 17     17   17153 use 5.010;
  17         47  
5              
6 17     17   58 use Scalar::Util qw(looks_like_number);
  17         15  
  17         718  
7              
8 17     17   489 use Class::Tiny::Antlers;
  17         3947  
  17         78  
9 17     17   1872 use namespace::clean;
  17         9380  
  17         82  
10              
11             extends 'Statistics::R::REXP::Vector';
12 17     17   2966 use overload;
  17         698  
  17         70  
13              
14              
15 17     17   591 use constant sexptype => 'REALSXP';
  17         22  
  17         3419  
16              
17 19     19   44 sub _type { 'double'; }
18              
19              
20             sub BUILDARGS {
21 901     901 0 121980 my $class = shift;
22 901         3346 my $attributes = $class->SUPER::BUILDARGS(@_);
23              
24 900 100       2353 if (ref($attributes->{elements}) eq 'ARRAY') {
25             $attributes->{elements} = [
26 3535 100       7288 map { looks_like_number($_) ? $_ : undef }
27 887         934 Statistics::R::REXP::Vector::_flatten(@{$attributes->{elements}})
  887         2698  
28             ]
29             }
30             $attributes
31 900         1776 }
32              
33              
34             sub BUILD {
35 897     897 0 20871 my ($self, $args) = @_;
36              
37             # Required attribute type
38             die "Elements of the 'elements' attribute must be numbers or undef" if defined($self->elements) &&
39 897 100 33     12502 grep { defined($_) && !looks_like_number($_) } @{$self->elements}
  3535 50       14822  
  897         14977  
40             }
41              
42              
43             1; # End of Statistics::R::REXP::Double
44              
45             __END__