File Coverage

blib/lib/Data/MARC/Field008/MixedMaterial.pm
Criterion Covered Total %
statement 30 31 96.7
branch 4 6 66.6
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 42 46 91.3


line stmt bran cond sub pod time code
1             package Data::MARC::Field008::MixedMaterial;
2              
3 5     5   135226 use strict;
  5         12  
  5         243  
4 5     5   34 use warnings;
  5         11  
  5         379  
5              
6 5     5   5287 use Data::MARC::Field008::Utils qw(check_item_form);
  5         24  
  5         164  
7 5     5   2545 use Error::Pure qw(err);
  5         17  
  5         396  
8 5     5   37 use Error::Pure::Utils qw(clean err_get);
  5         11  
  5         132  
9 5     5   3414 use Mo qw(build is);
  5         3555  
  5         29  
10 5     5   12923 use Mo::utils 0.22 qw(check_length_fix check_required check_strings);
  5         19284  
  5         198  
11              
12             our $STRICT = 1;
13              
14             our $VERSION = 0.04;
15              
16             has form_of_item => (
17             is => 'ro',
18             );
19              
20             has raw => (
21             is => 'ro',
22             );
23              
24             sub BUILD {
25 7     7 0 1079065 my $self = shift;
26              
27             # Check 'raw'
28 7         34 check_length_fix($self, 'raw', 17);
29              
30             # Check 'form_of_item'.
31 6         114 eval { check_item_form($self, 'form_of_item'); };
  6         33  
32              
33 6 50       3448 if ($STRICT) {
34 6         29 my @errors = err_get();
35 6 100       70 if (@errors) {
36 1 50       7 err "Couldn't create data object of mixed material.",
37             defined $self->raw ? ('Raw string', $self->raw) : (),
38             ;
39             }
40             } else {
41 0         0 clean();
42             }
43              
44 5         15 return;
45             }
46              
47             1;
48              
49             __END__
50              
51             =pod
52              
53             =encoding utf8
54              
55             =head1 NAME
56              
57             Data::MARC::Field008::MixedMaterial - Data object for MARC field 008 mixed material.
58              
59             =head1 SYNOPSIS
60              
61             use Data::MARC::Field008::MixedMaterial;
62              
63             my $obj = Data::MARC::Field008::MixedMaterial->new(%params);
64             my $form_of_item = $obj->form_of_item;
65             my $raw = $obj->form_of_item;
66              
67             =head1 METHODS
68              
69             =head2 C<new>
70              
71             my $obj = Data::MARC::Field008::MixedMaterial->new(%params);
72              
73             Constructor.
74              
75             =over 8
76              
77             =item * C<form_of_item>
78              
79             Form of item. The length of the item is 1 character.
80             Possible characters are ' ', 'a', 'b', 'c', 'd', 'f', 'o', 'q', 'r', 's' or '|'.
81              
82             It's required.
83              
84             Default value is undef.
85              
86             =item * C<raw>
87              
88             Raw string of material. The length of the string is 17 characters.
89              
90             It's optional.
91              
92             Default value is undef.
93              
94             =back
95              
96             Returns instance of object.
97              
98             =head2 C<form_of_item>
99              
100             my $form_of_item = $obj->form_of_item;
101              
102             Get form of item.
103              
104             Returns string
105              
106             =head2 C<raw>
107              
108             my $raw = $obj->form_of_item;
109              
110             Get raw string of the block.
111              
112             Returns string.
113              
114             =head1 ERRORS
115              
116             new():
117             Couldn't create data object of mixed material.
118             Raw string: %s
119             Parameter 'raw' has length different than '17'.
120             Value: %s
121             From Data::MARC::Field008::Utils::check_item_form():
122             Parameter 'form_of_item' has bad value.
123             Value: %s
124             Parameter 'form_of_item' is required.
125             Parameter 'form_of_item' length is bad.
126             Length: %s
127             Value: %s
128             Expected length: 1
129             Parameter 'form_of_item' must be a scalar value.
130             Reference: %s
131              
132             =head1 EXAMPLE
133              
134             =for comment filename=create_and_dump_marc_field_008_mixed_material.pl
135              
136             use strict;
137             use warnings;
138              
139             use Data::Printer;
140             use Data::MARC::Field008::MixedMaterial;
141              
142             my $obj = Data::MARC::Field008::MixedMaterial->new(
143             'form_of_item' => 'o',
144             # 89012345678901234
145             'raw' => ' o ',
146             );
147              
148             # Print out.
149             p $obj;
150              
151             # Output:
152             # Data::MARC::Field008::MixedMaterial {
153             # parents: Mo::Object
154             # public methods (7):
155             # BUILD
156             # Data::MARC::Field008::Utils:
157             # check_item_form
158             # Error::Pure:
159             # err
160             # Error::Pure::Utils:
161             # err_get
162             # Mo::utils:
163             # check_length_fix, check_required, check_strings
164             # private methods (0)
165             # internals: {
166             # form_of_item "o",
167             # raw " o "
168             # }
169             # }
170              
171             =head1 DEPENDENCIES
172              
173             L<Data::MARC::Field008::Utils>,
174             L<Error::Pure>
175             L<Error::Pure::Utils>
176             L<Mo>,
177             L<Mo::utils>.
178              
179             =head1 REPOSITORY
180              
181             L<https://github.com/michal-josef-spacek/Data-MARC-Field008>
182              
183             =head1 AUTHOR
184              
185             Michal Josef Špaček L<mailto:skim@cpan.org>
186              
187             L<http://skim.cz>
188              
189             =head1 LICENSE AND COPYRIGHT
190              
191             © 2025 Michal Josef Špaček
192              
193             BSD 2-Clause License
194              
195             =head1 ACKNOWLEDGEMENTS
196              
197             Development of this software has been made possible by institutional support
198             for the long-term strategic development of the National Library of the Czech
199             Republic as a research organization provided by the Ministry of Culture of
200             the Czech Republic (DKRVO 2024–2028), Area 11: Linked Open Data.
201              
202             =head1 VERSION
203              
204             0.04
205              
206             =cut