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.0';
4 11     11   16183 use 5.010;
  11         23  
5              
6 11     11   36 use Scalar::Util qw(looks_like_number blessed);
  11         13  
  11         565  
7              
8 11     11   481 use Class::Tiny::Antlers qw(-default around);
  11         4496  
  11         50  
9 11     11   1412 use namespace::clean;
  11         9867  
  11         45  
10              
11             extends 'Statistics::R::REXP';
12              
13             has sexptype => (
14             is => 'ro',
15             );
16              
17             use overload
18 11     11   2619 '""' => sub { 'Unknown' };
  11     13   689  
  11         68  
  13         30  
19              
20             sub BUILDARGS {
21 36     36 0 75788 my $class = shift;
22 36         56 my $attributes = {};
23            
24 36 100       136 if ( scalar @_ == 1) {
    100          
25 3 50       8 if ( ref $_[0] eq 'HASH' ) {
26 0         0 $attributes = $_[0]
27             }
28             else {
29 3         4 $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         76 $attributes = { @_ };
38             }
39            
40 35 100 66     171 if (blessed($attributes->{sexptype}) &&
41             $attributes->{sexptype}->isa('Statistics::R::REXP::Unknown')) {
42             $attributes->{sexptype} = $attributes->{sexptype}->sexptype
43 1         24 }
44             $attributes
45 35         69 }
46              
47              
48             sub BUILD {
49 34     34 0 456 my ($self, $args) = @_;
50              
51 34 100 66     565 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 453 }
66              
67              
68             1; # End of Statistics::R::REXP::Unknown
69              
70             __END__