File Coverage

blib/lib/Statistics/R/REXP/Raw.pm
Criterion Covered Total %
statement 28 29 96.5
branch 6 6 100.0
condition 4 6 66.6
subroutine 8 9 88.8
pod 0 2 0.0
total 46 52 88.4


line stmt bran cond sub pod time code
1             package Statistics::R::REXP::Raw;
2             # ABSTRACT: an R raw vector
3             $Statistics::R::REXP::Raw::VERSION = '1.0002';
4 14     14   47302 use 5.010;
  14         43  
5              
6 14     14   99 use Scalar::Util qw(looks_like_number);
  14         97  
  14         652  
7              
8 14     14   347 use Class::Tiny::Antlers;
  14         2996  
  14         63  
9 14     14   1809 use namespace::clean;
  14         8913  
  14         78  
10              
11             extends 'Statistics::R::REXP::Vector';
12 14     14   3604 use overload;
  14         700  
  14         59  
13              
14              
15 14     14   593 use constant sexptype => 'RAWSXP';
  14         31  
  14         2961  
16              
17 0     0   0 sub _type { 'raw'; }
18              
19              
20             sub BUILDARGS {
21 90     90 0 27821 my $class = shift;
22 90         421 my $attributes = $class->SUPER::BUILDARGS(@_);
23              
24 89 100       357 if (ref($attributes->{elements}) eq 'ARRAY') {
25             $attributes->{elements} = [
26             map int,
27 75         155 Statistics::R::REXP::Vector::_flatten(@{$attributes->{elements}})
  75         290  
28             ]
29             }
30             $attributes
31 89         240 }
32              
33              
34             sub BUILD {
35 87     87 0 2452 my ($self, $args) = @_;
36              
37             # Required attribute type
38 87 100       1347 die 'Raw vectors cannot have attributes' if defined $self->attributes;
39             die 'Elements of raw vectors must be 0-255' if defined $self->elements &&
40 86 100 66     1551 grep { !($_ >= 0 && $_ <= 255) } @{$self->elements}
  265   66     1165  
  86         1685  
41             }
42              
43              
44             1; # End of Statistics::R::REXP::Raw
45              
46             __END__