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.0001';
4 19     19   17234 use 5.010;
  19         50  
5              
6 19     19   62 use Scalar::Util qw(looks_like_number);
  19         15  
  19         721  
7              
8 19     19   486 use Class::Tiny::Antlers;
  19         3871  
  19         83  
9 19     19   1938 use namespace::clean;
  19         9262  
  19         82  
10              
11             extends 'Statistics::R::REXP::Vector';
12 19     19   3146 use overload;
  19         692  
  19         72  
13              
14              
15 19     19   589 use constant sexptype => 'REALSXP';
  19         24  
  19         3661  
16              
17 19     19   36 sub _type { 'double'; }
18              
19              
20             sub BUILDARGS {
21 1671     1671 0 127697 my $class = shift;
22 1671         4694 my $attributes = $class->SUPER::BUILDARGS(@_);
23              
24 1670 100       3871 if (ref($attributes->{elements}) eq 'ARRAY') {
25             $attributes->{elements} = [
26 7083 100       12956 map { looks_like_number($_) ? $_ : undef }
27 1656         1584 Statistics::R::REXP::Vector::_flatten(@{$attributes->{elements}})
  1656         4343  
28             ]
29             }
30             $attributes
31 1670         3007 }
32              
33              
34             sub BUILD {
35 1667     1667 0 38033 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 1667 100 33     22398 grep { defined($_) && !looks_like_number($_) } @{$self->elements}
  7083 50       26908  
  1667         27312  
40             }
41              
42              
43             1; # End of Statistics::R::REXP::Double
44              
45             __END__