File Coverage

blib/lib/Archive/Rgssad/Entry.pm
Criterion Covered Total %
statement 19 19 100.0
branch 4 4 100.0
condition 4 4 100.0
subroutine 6 6 100.0
pod 3 3 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package Archive::Rgssad::Entry;
2              
3 4     4   811 use 5.010;
  4         13  
  4         291  
4 4     4   20 use strict;
  4         8  
  4         136  
5 4     4   19 use warnings FATAL => 'all';
  4         23  
  4         1076  
6              
7             =head1 NAME
8              
9             Archive::Rgssad::Entry - A (path, data) pair in rgssad archive.
10              
11             =cut
12              
13             our $VERSION = '0.1';
14              
15             =head1 SYNOPSIS
16              
17             use Archive::Rgssad::Entry;
18              
19             # create a new entry
20             my $entry = Archive::Rgssad::Entry->new($path, $data);
21              
22             # update path and data
23             $entry->path($new_path);
24             $entry->data($new_data);
25              
26             # save the entry to file
27             open FH, '>', $entry->path;
28             print FH $entry->data;
29             close FH;
30              
31             =head1 DESCRIPTION
32              
33             Each entry in rgssad archive is simply a (path, data) pair.
34              
35             =head2 Constructor
36              
37             =over 4
38              
39             =item new([$path [, $data]])
40              
41             Create a new entry.
42              
43             =back
44              
45             =cut
46              
47             sub new {
48 13     13 1 26 my $class = shift;
49 13   100     106 my $self = {
      100        
50             path => $_[0] // '',
51             data => $_[1] // ''
52             };
53 13         28 bless $self, $class;
54 13         69 return $self;
55             }
56              
57             =head2 Accessors
58              
59             =over 4
60              
61             =item path([$new_path])
62              
63             Return the path of the entry. If $new_path is given, set the path to $new_path and return it.
64              
65             =cut
66              
67             sub path {
68 69     69 1 2916 my $self = shift;
69 69 100       138 $self->{path} = shift if @_;
70 69         204 return $self->{path};
71             }
72              
73             =item data([$new_data])
74              
75             Return the data of the entry. If $new_data is given, set the data to $new_data and return it.
76              
77             =cut
78              
79             sub data {
80 36     36 1 45 my $self = shift;
81 36 100       80 $self->{data} = shift if @_;
82 36         103 return $self->{data};
83             }
84              
85             =back
86              
87             =head1 AUTHOR
88              
89             Zejun Wu, C<< >>
90              
91              
92             =head1 SUPPORT
93              
94             You can find documentation for this module with the perldoc command.
95              
96             perldoc Archive::Rgssad::Entry
97              
98              
99             You can also look for information at:
100              
101             =over 4
102              
103             =item * GitHub
104              
105             L
106              
107             =back
108              
109              
110             =head1 LICENSE AND COPYRIGHT
111              
112             Copyright 2012 Zejun Wu.
113              
114             This program is free software; you can redistribute it and/or modify it
115             under the terms of either: the GNU General Public License as published
116             by the Free Software Foundation; or the Artistic License.
117              
118             See L for more information.
119              
120              
121             =cut
122              
123             1; # End of Archive::Rgssad::Entry