Object/Work.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 96.9% 32 / 33 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Object/Publisher.pm ↑ Summary Object/Kramerius.pm »
1 package MARC::Convert::Wikidata::Object::Work;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Mo qw(build default is);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Mo::utils 0.21 qw(check_isa check_required);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Mo::utils::Array qw(check_array_object);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 our $VERSION = 0.15;
11  
12 3 has author => (
13 is => 'ro',
14 );
15  
16 3 has external_ids => (
17 default => [],
18 is => 'ro',
19 );
20  
21 3 has title => (
22 is => 'ro',
23 );
24  
25 3 has title_language => (
26 is => 'ro',
27 );
28  
29 sub BUILD {
30 2 ▶ my $self = shift;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
31  
32 # Check 'author'.
33 2 check_isa($self, 'author', 'MARC::Convert::Wikidata::Object::People');
34  
35 # Check 'external_ids'.
36 2 check_array_object($self, 'external_ids', 'MARC::Convert::Wikidata::Object::ExternalId');
37  
38 # Check 'title'.
39 2 check_required($self, 'title');
40  
41 1 return;
42 }
43  
44 3 1;
45  
46 __END__
47  
48 =pod
49  
50 =encoding utf8
51  
52 =head1 NAME
53  
54 MARC::Convert::Wikidata::Object::Work - Bibliographic Wikidata object for work defined by MARC record.
55  
56 =head1 SYNOPSIS
57  
58 use MARC::Convert::Wikidata::Object::Work;
59  
60 my $obj = MARC::Convert::Wikidata::Object::Work->new(%params);
61 my $author = $obj->author;
62 my $external_ids_ar = $obj->external_ids;
63 my $title = $obj->title;
64 my $title_language = $obj->title_language;
65  
66 =head1 METHODS
67  
68 =head2 C<new>
69  
70 my $obj = MARC::Convert::Wikidata::Object::Work->new(%params);
71  
72 Constructor.
73  
74 Returns instance of object.
75  
76 =over 8
77  
78 =item * C<author>
79  
80 Author of work.
81  
82 Possible value is reference L<MARC::Convert::Wikidata::Object::People> instance.
83  
84 Default value is undef.
85  
86 =item * C<external_ids>
87  
88 External ids.
89  
90 Need to be a reference to array with L<MARC::Convert::Wikidata::Object::ExternalId> instances.
91  
92 Default value is [].
93  
94 =item * C<title>
95  
96 Work title.
97  
98 It's required.
99  
100 Default value is undef.
101  
102 =item * C<title_language>
103  
104 Work title language.
105  
106 Default value is undef.
107  
108 =back
109  
110 =head2 C<author>
111  
112 my $author = $obj->author;
113  
114 Get author of work.
115  
116 Returns L<MARC::Convert::Wikidata::Object::People> instance.
117  
118 =head2 C<external_ids>
119  
120 my $external_ids_ar = $obj->external_ids;
121  
122 Get list of external ids.
123  
124 Returns reference to array with L<MARC::Convert::Wikidata::Object::ExternalId> instances.
125  
126 =head2 C<title>
127  
128 my $title = $obj->title;
129  
130 Get work title.
131  
132 Returns string.
133  
134 =head2 C<title_language>
135  
136 my $title_language = $obj->title_language;
137  
138 Get work title language.
139  
140 Returns string.
141  
142 =head1 ERRORS
143  
144 new():
145 From Mo::utils::Array::check_array_object():
146 Parameter 'external_ids' must be a array.
147 Value: %s
148 Reference: %s
149 Parameter 'external_ids' with array must contain 'MARC::Convert::Wikidata::Object::ExternalId' objects.
150 Value: %s
151 Reference: %s
152  
153 From Mo::utils::Date::check_isa():
154 Parameter 'author' must be a 'MARC::Convert::Wikidata::Object::People' object.
155 Value: %s
156 Reference: %s
157  
158 From Mo::utils::Date::check_required():
159 Parameter 'title' is required.
160
161  
162 =head1 EXAMPLE1
163  
164 =for comment filename=create_and_dump_work.pl
165  
166 use strict;
167 use warnings;
168  
169 use Data::Printer;
170 use MARC::Convert::Wikidata::Object::ExternalId;
171 use MARC::Convert::Wikidata::Object::People;
172 use MARC::Convert::Wikidata::Object::Work;
173 use Unicode::UTF8 qw(decode_utf8);
174
175 my $obj = MARC::Convert::Wikidata::Object::Work->new(
176 'author' => MARC::Convert::Wikidata::Object::People->new(
177 'name' => decode_utf8('Tomáš Garrigue'),
178 'surname' => 'Masaryk',
179 ),
180 'external_ids' => [
181 MARC::Convert::Wikidata::Object::ExternalId->new(
182 'name' => 'nkcr_aut',
183 'value' => 'jn20000401266',
184 ),
185 ],
186 'title' => decode_utf8('O ethice a alkoholismu'),
187 'title_language' => 'cze',
188 );
189
190 p $obj;
191  
192 # Output:
193 # MARC::Convert::Wikidata::Object::Work {
194 # parents: Mo::Object
195 # public methods (4):
196 # BUILD
197 # Mo::utils:
198 # check_isa, check_required
199 # Mo::utils::Array:
200 # check_array_object
201 # private methods (0)
202 # internals: {
203 # author MARC::Convert::Wikidata::Object::People,
204 # external_ids [
205 # [0] MARC::Convert::Wikidata::Object::ExternalId
206 # ],
207 # title "O ethice a alkoholismu",
208 # title_language "cze"
209 # }
210 # }
211  
212 =head1 DEPENDENCIES
213  
214 L<Mo>,
215 L<Mo::utils>,
216 L<Mo::utils::Array>.
217  
218 =head1 SEE ALSO
219  
220 =over
221  
222 =item L<MARC::Convert::Wikidata>
223  
224 Conversion class between MARC record and Wikidata object.
225  
226 =back
227  
228 =head1 REPOSITORY
229  
230 L<https://github.com/michal-josef-spacek/MARC-Convert-Wikidata-Object>
231  
232 =head1 AUTHOR
233  
234 Michal Josef Špaček L<mailto:skim@cpan.org>
235  
236 L<http://skim.cz>
237  
238 =head1 LICENSE AND COPYRIGHT
239  
240 © Michal Josef Špaček 2021-2025
241  
242 BSD 2-Clause License
243  
244 =head1 VERSION
245  
246 0.15
247  
248 =cut
« Object/Publisher.pm ↑ Summary Object/Kramerius.pm »