File: RDS.pm

package info (click to toggle)
libstatistics-r-io-perl 1.0002-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,824 kB
  • sloc: perl: 10,895; makefile: 2
file content (101 lines) | stat: -rw-r--r-- 2,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package Statistics::R::IO::RDS;
# ABSTRACT: Supply object methods for RDS files
$Statistics::R::IO::RDS::VERSION = '1.0002';
use 5.010;

use Class::Tiny::Antlers;

extends 'Statistics::R::IO::Base';

use Statistics::R::IO::REXPFactory;
use Carp;

use namespace::clean;


sub read {
    my $self = shift;
    
    my $data = $self->_read_and_uncompress;
    
    my ($value, $state) = @{Statistics::R::IO::REXPFactory::unserialize($data)};
    croak 'Could not parse RDS file' unless $state;
    croak 'Unread data remaining in the RDS file' unless $state->eof;
    $value
}


1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Statistics::R::IO::RDS - Supply object methods for RDS files

=head1 VERSION

version 1.0002

=head1 SYNOPSIS

    use Statistics::R::IO::RDS;
    
    my $rds = Statistics::R::IO::RDS->new('file.rds');
    my $var = $rds->read;
    print $var->to_pl;
    $rds->close;

=head1 DESCRIPTION

C<Statistics::R::IO::RDS> provides an object-oriented interface to
parsing RDS files. RDS files store a serialization of a single R
object (and, if the object contains references to other objects, such
as environments, all the referenced objects as well). These files are
created in R using the C<readRDS> function and are typically named
with the C<.rds> file extension.

=head1 METHODS

C<Statistics::R::IO::RDS> inherits from L<Statistics::R::IO::Base> and
provides an implementation for the L</read> method that parses RDS
files.

=over

=item read

Reads the contents of the filehandle and returns a
L<Statistics::R::REXP>.

=back

=head1 BUGS AND LIMITATIONS

Instances of this class are intended to be immutable. Please do not
try to change their value or attributes.

There are no known bugs in this module. Please see
L<Statistics::R::IO> for bug reporting.

=head1 SUPPORT

See L<Statistics::R::IO> for support and contact information.

=head1 AUTHOR

Davor Cubranic <cubranic@stat.ubc.ca>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by University of British Columbia.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007

=cut