File Coverage

blib/lib/Statistics/R/REXP/Unknown.pm
Criterion Covered Total %
statement 28 29 96.5
branch 9 10 90.0
condition 6 9 66.6
subroutine 9 9 100.0
pod 1 3 33.3
total 53 60 88.3


line stmt bran cond sub pod time code
1             package Statistics::R::REXP::Unknown;
2             # ABSTRACT: R object not representable in Rserve
3             $Statistics::R::REXP::Unknown::VERSION = '1.0002';
4 12     12   51840 use 5.010;
  12         36  
5              
6 12     12   58 use Scalar::Util qw(looks_like_number blessed);
  12         21  
  12         677  
7              
8 12     12   335 use Class::Tiny::Antlers qw(-default around);
  12         3015  
  12         69  
9 12     12   1790 use namespace::clean;
  12         8926  
  12         55  
10              
11             extends 'Statistics::R::REXP';
12              
13             has sexptype => (
14             is => 'ro',
15             );
16              
17             use overload
18 12     12   3905 '""' => sub { 'Unknown' };
  12     13   697  
  12         81  
  13         46  
19              
20             sub BUILDARGS {
21 36     36 0 5977 my $class = shift;
22 36         73 my $attributes = {};
23            
24 36 100       154 if ( scalar @_ == 1) {
    100          
25 3 50       15 if ( ref $_[0] eq 'HASH' ) {
26 0         0 $attributes = $_[0]
27             }
28             else {
29 3         7 $attributes->{sexptype} = $_[0]
30             }
31             }
32             elsif ( @_ % 2 ) {
33 1         7 die "The new() method for $class expects a hash reference or a key/value list."
34             . " You passed an odd number of arguments\n";
35             }
36             else {
37 32         102 $attributes = { @_ };
38             }
39            
40 35 100 66     170 if (blessed($attributes->{sexptype}) &&
41             $attributes->{sexptype}->isa('Statistics::R::REXP::Unknown')) {
42             $attributes->{sexptype} = $attributes->{sexptype}->sexptype
43 1         21 }
44             $attributes
45 35         88 }
46              
47              
48             sub BUILD {
49 34     34 0 503 my ($self, $args) = @_;
50              
51 34 100 66     536 die "Attribute 'sexptype' must be a number in range 0-255" unless
      66        
52             looks_like_number($self->sexptype) &&
53             ($self->sexptype >= 0) && ($self->sexptype <= 255)
54             }
55              
56              
57             around _eq => sub {
58             my $orig = shift;
59             $orig->(@_) and ($_[0]->sexptype eq $_[1]->sexptype);
60             };
61              
62              
63             sub to_pl {
64             undef
65 1     1 1 676 }
66              
67              
68             1; # End of Statistics::R::REXP::Unknown
69              
70             __END__