File Coverage

blib/lib/Statistics/R/REXP/Character.pm
Criterion Covered Total %
statement 25 25 100.0
branch 3 4 75.0
condition 1 3 33.3
subroutine 8 8 100.0
pod 0 2 0.0
total 37 42 88.1


line stmt bran cond sub pod time code
1             package Statistics::R::REXP::Character;
2             # ABSTRACT: an R character vector
3             $Statistics::R::REXP::Character::VERSION = '1.0';
4 17     17   18533 use 5.010;
  17         48  
5              
6 17     17   529 use Class::Tiny::Antlers;
  17         4044  
  17         93  
7 17     17   1930 use namespace::clean;
  17         9462  
  17         68  
8              
9             extends 'Statistics::R::REXP::Vector';
10 17     17   13414 use overload;
  17         9195  
  17         84  
11              
12              
13 17     17   710 use constant sexptype => 'STRSXP';
  17         18  
  17         3051  
14              
15 411     411   1158 sub _type { 'character'; }
16              
17              
18             sub BUILDARGS {
19 2086     2086 0 160758 my $class = shift;
20 2086         5916 my $attributes = $class->SUPER::BUILDARGS(@_);
21              
22 2085 100       4894 if (ref($attributes->{elements}) eq 'ARRAY') {
23             $attributes->{elements} = [
24 2066         1833 Statistics::R::REXP::Vector::_flatten(@{$attributes->{elements}})
  2066         4930  
25             ]
26             }
27             $attributes
28 2085         3647 }
29              
30              
31             sub BUILD {
32 2082     2082 0 46477 my ($self, $args) = @_;
33              
34             # Required attribute type
35             die "Elements of the 'elements' attribute must be scalar values" if defined($self->elements) &&
36 2082 50 33     28249 grep { ref($_) } @{$self->elements}
  6079         15700  
  2082         34152  
37             }
38              
39              
40             1; # End of Statistics::R::REXP::Character
41              
42             __END__