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.0001';
4 12     12   20555 use 5.010;
  12         26  
5              
6 12     12   39 use Scalar::Util qw(looks_like_number blessed);
  12         12  
  12         550  
7              
8 12     12   554 use Class::Tiny::Antlers qw(-default around);
  12         3874  
  12         54  
9 12     12   1484 use namespace::clean;
  12         9439  
  12         48  
10              
11             extends 'Statistics::R::REXP';
12              
13             has sexptype => (
14             is => 'ro',
15             );
16              
17             use overload
18 12     12   2669 '""' => sub { 'Unknown' };
  12     13   680  
  12         75  
  13         31  
19              
20             sub BUILDARGS {
21 36     36 0 72914 my $class = shift;
22 36         48 my $attributes = {};
23            
24 36 100       129 if ( scalar @_ == 1) {
    100          
25 3 50       7 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         8 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         65 $attributes = { @_ };
38             }
39            
40 35 100 66     173 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 425 my ($self, $args) = @_;
50              
51 34 100 66     517 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 422 }
66              
67              
68             1; # End of Statistics::R::REXP::Unknown
69              
70             __END__