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.0';
4 12     12   15444 use 5.010;
  12         23  
5              
6 12     12   38 use Scalar::Util qw(looks_like_number);
  12         14  
  12         569  
7              
8 12     12   469 use Class::Tiny::Antlers;
  12         3944  
  12         51  
9 12     12   1315 use namespace::clean;
  12         9347  
  12         40  
10              
11             extends 'Statistics::R::REXP::Vector';
12 12     12   2239 use overload;
  12         733  
  12         49  
13              
14              
15 12     12   381 use constant sexptype => 'RAWSXP';
  12         12  
  12         2260  
16              
17 0     0   0 sub _type { 'raw'; }
18              
19              
20             sub BUILDARGS {
21 59     59 0 84286 my $class = shift;
22 59         235 my $attributes = $class->SUPER::BUILDARGS(@_);
23              
24 58 100       171 if (ref($attributes->{elements}) eq 'ARRAY') {
25             $attributes->{elements} = [
26             map int,
27 45         50 Statistics::R::REXP::Vector::_flatten(@{$attributes->{elements}})
  45         135  
28             ]
29             }
30             $attributes
31 58         114 }
32              
33              
34             sub BUILD {
35 56     56 0 1298 my ($self, $args) = @_;
36              
37             # Required attribute type
38 56 100       788 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 55 100 66     893 grep { !($_ >= 0 && $_ <= 255) } @{$self->elements}
  155   66     617  
  55         959  
41             }
42              
43              
44             1; # End of Statistics::R::REXP::Raw
45              
46             __END__