File Coverage

blib/lib/Data/MARC/Field008/VisualMaterial.pm
Criterion Covered Total %
statement 39 41 95.1
branch 2 6 33.3
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 49 56 87.5


line stmt bran cond sub pod time code
1             package Data::MARC::Field008::VisualMaterial;
2              
3 9     9   179859 use strict;
  9         17  
  9         387  
4 9     9   63 use warnings;
  9         16  
  9         549  
5              
6 9         286 use Data::MARC::Field008::Utils qw(check_government_publication check_item_form
7             check_visual_material_running_time check_visual_material_technique
8 9     9   5665 check_target_audience);
  9         37  
9 9     9   2203 use Error::Pure qw(err);
  9         17  
  9         386  
10 9     9   41 use Error::Pure::Utils qw(clean err_get);
  9         12  
  9         209  
11 9     9   4853 use Mo qw(build is);
  9         5366  
  9         47  
12 9     9   17582 use Mo::utils 0.22 qw(check_length_fix check_required);
  9         23567  
  9         214  
13              
14             our $STRICT = 1;
15              
16             our $VERSION = 0.04;
17              
18             has form_of_item => (
19             is => 'ro',
20             );
21              
22             has government_publication => (
23             is => 'ro',
24             );
25              
26             has raw => (
27             is => 'ro',
28             );
29              
30             has running_time_for_motion_pictures_and_videorecordings => (
31             is => 'ro',
32             );
33              
34             has target_audience => (
35             is => 'ro',
36             );
37              
38             has technique => (
39             is => 'ro',
40             );
41              
42             has type_of_visual_material => (
43             is => 'ro',
44             );
45              
46             sub BUILD {
47 9     9 0 2206828 my $self = shift;
48              
49             # Check 'raw'
50 9         57 check_length_fix($self, 'raw', 17);
51              
52             # Check 'form_of_item'.
53 8         155 eval { check_item_form($self, 'form_of_item'); };
  8         56  
54              
55             # Check 'government_publication'.
56 8         16 eval { check_government_publication($self, 'government_publication'); };
  8         32  
57              
58             # Check 'running_time_for_motion_pictures_and_videorecordings'.
59 8         18 eval { check_visual_material_running_time($self, 'running_time_for_motion_pictures_and_videorecordings'); };
  8         82  
60              
61             # Check 'target_audience'.
62 8         18 eval { check_target_audience($self, 'target_audience'); };
  8         34  
63              
64             # Check 'technique'.
65 8         19 eval { check_visual_material_technique($self, 'technique'); };
  8         26  
66              
67             # Check 'type_of_visual_material'.
68 8         18 eval { check_visual_material_type($self, 'type_of_visual_material'); };
  8         284  
69              
70 8 50       83 if ($STRICT) {
71 8         94 my @errors = err_get();
72 8 50       170 if (@errors) {
73 0 0       0 err "Couldn't create data object of visual material.",
74             defined $self->raw ? ('Raw string', $self->raw) : (),
75             ;
76             }
77             } else {
78 0         0 clean();
79             }
80              
81 8         27 return;
82             }
83              
84             1;
85              
86             __END__
87              
88             =pod
89              
90             =encoding utf8
91              
92             =head1 NAME
93              
94             Data::MARC::Field008::VisualMaterial - Data object for MARC field 008 visual material.
95              
96             =head1 SYNOPSIS
97              
98             use Data::MARC::Field008::VisualMaterial;
99              
100             my $obj = Data::MARC::Field008::VisualMaterial->new(%params);
101             my $form_of_item = $obj->form_of_item;
102             my $government_publication = $obj->government_publication;
103             my $raw = $obj->raw;
104             my $running_time_for_motion_pictures_and_videorecordings = $obj->running_time_for_motion_pictures_and_videorecordings;
105             my $target_audience = $obj->target_audience;
106             my $technique = $obj->technique;
107             my $type_of_visual_material = $obj->type_of_visual_material;
108              
109             =head1 METHODS
110              
111             =head2 C<new>
112              
113             my $obj = Data::MARC::Field008::VisualMaterial->new(%params);
114              
115             Constructor.
116              
117             =over 8
118              
119             =item * C<form_of_item>
120              
121             Form of item. The length of the item is 1 character.
122             Possible characters are ' ', 'a', 'b', 'c', 'd', 'f', 'o', 'q', 'r', 's' or '|'.
123              
124             It's required.
125              
126             Default value is undef.
127              
128             =item * C<government_publication>
129              
130             Government publication. The length of the string is 1 character.
131             Possible characters are ' ', 'a', 'c', 'f', 'i', 'l', 'm', 'o', 's', 'u', 'z' or '|'.
132              
133             It's required.
134              
135             Default value is undef.
136              
137             =item * C<raw>
138              
139             Raw string of material. The length of the string is 17 characters.
140              
141             It's optional.
142              
143             Default value is undef.
144              
145             =item * C<running_time_for_motion_pictures_and_videorecordings>
146              
147             Running time for motion pictures and videorecordings. The length of the string is 3 characters.
148             Possible strings are decimal string, 'nnn', '---' or '|||'.
149              
150             It's required.
151              
152             Default value is undef.
153              
154             =item * C<target_audience>
155              
156             Target audience. The length of the item is 1 character.
157             Possible characters are ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'j' or '|'.
158              
159             It's required.
160              
161             Default value is undef.
162              
163             =item * C<technique>
164              
165             Technique. The length of the string is 1 character.
166             Possible characters are 'a', 'c', 'l', 'n', 'u', 'z' or '|'.
167              
168             It's required.
169              
170             Default value is undef.
171              
172             =item * C<type_of_visual_material>
173              
174             Type of visual material. The length of the string is 1 character.
175             Possible characters are 'a', 'b', 'c', 'd', 'f', 'g', 'i', 'k', 'l', 'm', 'n',
176             'o', 'p', 'q', 'r', 's', 't', 'v', 'w', 'z' or '|'.
177              
178             It's required.
179              
180             Default value is undef.
181              
182             =back
183              
184             Returns instance of object.
185              
186             =head2 C<form_of_item>
187              
188             my $form_of_item = $obj->form_of_item;
189              
190             Get for of item.
191              
192             Returns string.
193              
194             =head2 C<government_publication>
195              
196             my $government_publication = $obj->government_publication;
197              
198             Get governent publication.
199              
200             Returns string.
201              
202             =head2 C<raw>
203              
204             my $raw = $obj->raw;
205              
206             Get raw string of the block.
207              
208             Returns string.
209              
210             =head2 C<running_time_for_motion_pictures_and_videorecordings>
211              
212             my $running_time_for_motion_pictures_and_videorecordings = $obj->running_time_for_motion_pictures_and_videorecordings;
213              
214             Get running time for motion pictures and videorecordings.
215              
216             Returns string.
217              
218             =head2 C<target_audience>
219              
220             my $target_audience = $obj->target_audience;
221              
222             Get target audience.
223              
224             Returns string.
225              
226             =head2 C<technique>
227              
228             my $technique = $obj->technique;
229              
230             Get technique.
231              
232             Returns string.
233              
234             =head2 C<type_of_visual_material>
235              
236             my $type_of_visual_material = $obj->type_of_visual_material;
237              
238             Get type of visual material.
239              
240             Returns string.
241              
242             =head1 ERRORS
243              
244             new():
245             Couldn't create data object of visual material.
246             Raw string: %s
247             Parameter 'raw' has length different than '17'.
248             Value: %s
249             From Data::MARC::Field008::Utils::check_government_publication():
250             Parameter 'government_publication' has bad value.
251             Value: %s
252             Parameter 'government_publication' is required.
253             Parameter 'government_publication' length is bad.
254             Length: %s
255             Value: %s
256             Expected length: 1
257             Parameter 'government_publication' must be a scalar value.
258             Reference: %s
259             From Data::MARC::Field008::Utils::check_item_form():
260             Parameter 'form_of_item' has bad value.
261             Value: %s
262             Parameter 'form_of_item' is required.
263             Parameter 'form_of_item' length is bad.
264             Length: %s
265             Value: %s
266             Expected length: 1
267             Parameter 'form_of_item' must be a scalar value.
268             Reference: %s
269             From Data::MARC::Field008::Utils::check_visual_material_running_time():
270             Parameter 'running_time_for_motion_pictures_and_videorecordings' contains bad visual material running time.
271             Value: %s
272             Parameter 'running_time_for_motion_pictures_and_videorecordings' has value with 'n' character.
273             Value: %s
274             Parameter 'running_time_for_motion_pictures_and_videorecordings' has value with dash character.
275             Value: %s
276             Parameter 'running_time_for_motion_pictures_and_videorecordings' has value with pipe character.
277             Value: %s
278             Parameter 'running_time_for_motion_pictures_and_videorecordings' is required.
279             Parameter 'running_time_for_motion_pictures_and_videorecordings' length is bad.
280             Length: %s
281             Value: %s
282             Expected length: %s
283             Parameter 'running_time_for_motion_pictures_and_videorecordings' must be a scalar value.
284             Reference: %s
285             From Data::MARC::Field008::Utils::check_visual_material_technique():
286             Parameter 'technique' has bad value.
287             Value: %s
288             Parameter 'technique' is required.
289             Parameter 'technique' length is bad.
290             Length: %s
291             Value: %s
292             Expected length: 1
293             Parameter 'technique' must be a scalar value.
294             Reference: %s
295             From Data::MARC::Field008::Utils::check_target_audience():
296             Parameter 'target_audience' has bad value.
297             Value: %s
298             Parameter 'target_audience' is required.
299             Parameter 'target_audience' length is bad.
300             Length: %s
301             Value: %s
302             Expected length: 1
303             Parameter 'target_audience' must be a scalar value.
304             Reference: %s
305              
306             =head1 EXAMPLE
307              
308             =for comment filename=create_and_dump_marc_field_008_visual_material.pl
309              
310             use strict;
311             use warnings;
312              
313             use Data::Printer;
314             use Data::MARC::Field008::VisualMaterial;
315              
316             # cnb000027064
317             my $obj = Data::MARC::Field008::VisualMaterial->new(
318             'form_of_item' => ' ',
319             'government_publication' => ' ',
320             # 89012345678901234
321             'raw' => 'nnn g kn',
322             'running_time_for_motion_pictures_and_videorecordings' => 'nnn',
323             'target_audience' => 'g',
324             'technique' => 'n',
325             'type_of_visual_material' => 'k',
326             );
327              
328             # Print out.
329             p $obj;
330              
331             # Output:
332             # Data::MARC::Field008::VisualMaterial {
333             # parents: Mo::Object
334             # public methods (10):
335             # BUILD
336             # Data::MARC::Field008::Utils:
337             # check_government_publication, check_item_form, check_target_audience, check_visual_material_running_time, check_visual_material_technique
338             # Error::Pure:
339             # err
340             # Error::Pure::Utils:
341             # err_get
342             # Mo::utils:
343             # check_length_fix, check_required
344             # private methods (0)
345             # internals: {
346             # form_of_item " ",
347             # government_publication " ",
348             # raw "nnn g kn",
349             # running_time_for_motion_pictures_and_videorecordings "nnn",
350             # target_audience "g",
351             # technique "n",
352             # type_of_visual_material "k"
353             # }
354             # }
355              
356             =head1 DEPENDENCIES
357              
358             L<Data::MARC::Field008::Utils>,
359             L<Error::Pure>
360             L<Error::Pure::Utils>
361             L<Mo>,
362             L<Mo::utils>.
363              
364             =head1 REPOSITORY
365              
366             L<https://github.com/michal-josef-spacek/Data-MARC-Field008>
367              
368             =head1 AUTHOR
369              
370             Michal Josef Špaček L<mailto:skim@cpan.org>
371              
372             L<http://skim.cz>
373              
374             =head1 LICENSE AND COPYRIGHT
375              
376             © 2025 Michal Josef Špaček
377              
378             BSD 2-Clause License
379              
380             =head1 ACKNOWLEDGEMENTS
381              
382             Development of this software has been made possible by institutional support
383             for the long-term strategic development of the National Library of the Czech
384             Republic as a research organization provided by the Ministry of Culture of
385             the Czech Republic (DKRVO 2024–2028), Area 11: Linked Open Data.
386              
387             =head1 VERSION
388              
389             0.04
390              
391             =cut