Record.pm

filter: Statementstmt 100% 19 / 19 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 23 / 23 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« RecordType.pm ↑ Summary
1 package xDT::Record;
2  
3 3 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use xDT::RecordType;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 xDT::Record - A xDT record
11  
12 =head1 VERSION
13  
14 Version 1.06
15  
16 =cut
17  
18 3 our $VERSION = '1.06';
19  
20  
21 =head1 SYNOPSIS
22  
23 Instances of this module correspond to records (lines) in a xDT file.
24 They provide some methods to acces fields and record type metadata.
25  
26 use xDT::Record;
27  
28 my $record = xDT::Record->new($line);
29 say 'Value: '. $record->get_value();
30 say 'Length: '. $record->get_length();
31  
32 my $record_type = $record->get_record_type();
33  
34 =head1 ATTRIBUTES
35  
36 =head2 length
37  
38 The length of this record.
39  
40 =cut
41  
42 3 has 'length' => (
43 is => 'ro',
44 isa => 'Str',
45 required => 1,
46 reader => 'get_length',
47 documentation => q{The length of this records value (there are 2 extra symbols at the end of the string).},
48 );
49  
50 =head2 record_type
51  
52 This records record type.
53  
54 =cut
55  
56 3 has 'record_type' => (
57 is => 'rw',
58 isa => 'Maybe[xDT::RecordType]',
59 required => 1,
60 writer => 'set_record_type',
61 reader => 'get_record_type',
62 handles => {
63 get_accessor => 'get_accessor',
64 get_labels => 'get_labels',
65 get_id => 'get_id',
66 get_type => 'get_type',
67 get_max_length => 'get_length',
68 is_object_end => 'is_object_end',
69 },
70 documentation => q{The record type of this record.},
71 );
72  
73 =head2 value
74  
75 The value of this record.
76  
77 =cut
78  
79 3 has 'value' => (
80 is => 'ro',
81 isa => 'Maybe[Str]',
82 reader => 'get_value',
83 documentation => q{The value of this record as string.},
84 );
85  
86  
87 around BUILDARGS => sub {
88 37 ▶ my ($orig, $class, $line) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
89  
90 37 my $value = substr($line, 7);
91 37 $value =~ s/\s*$//g;
92  
93 37 return $class->$orig(
94 length => substr($line, 0, 3),
95 record_type => undef,
96 value => $value,
97 );
98 3 };
99  
100 =head1 SUBROUTINES/METHODS
101  
102 =head2 get_length
103  
104 Returns the length of this record.
105  
106 =cut
107  
108 =head2 get_record_type
109  
110 Returns the record type of this record.
111  
112 =cut
113  
114 =head2 get_accessor
115  
116 Returns the accessor of the records record type.
117  
118 =cut
119  
120 =head2 get_labels
121  
122 Returns the labels of the records record type.
123  
124 =cut
125  
126 =head2 get_id
127  
128 Returns the id of the records record type.
129  
130 =cut
131  
132 =head2 get_type
133  
134 Returns the type of the records record type.
135  
136 =cut
137  
138 =head2 get_max_length
139  
140 Returns the maximum length of the records record type.
141  
142 =cut
143  
144 =head2 is_object_end
145  
146 Checks if the records record type is an end record.
147  
148 =cut
149  
150 =head2 get_value
151  
152 Returns the value of this record.
153  
154 =cut
155  
156 =head1 AUTHOR
157  
158 Christoph Beger, C<< <christoph.beger at medizin.uni-leipzig.de> >>
159  
160 =cut
161  
162 3 __PACKAGE__->meta->make_immutable;
163  
164 3 1; # End of xDT::Record
« RecordType.pm ↑ Summary