19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/relaton/iec/hit_collection.rb', line 19
def to_all_parts(r_year, opts = {}) parts = @array.select { |h| h.part && (!r_year || h.hit[:id]&.year&.to_s == r_year) }
if opts[:publication_date_before] || opts[:publication_date_after]
parts = parts.select { |h| Bibliography.send(:year_in_range?, h.hit[:id].year.to_i, opts) }
end
hit = parts.min_by { |h| h.part.to_i }
return @array.first&.item unless hit
bibitem = hit.item
all_parts_item = bibitem.to_all_parts
parts.reject { |h| h.hit[:id] == hit.hit[:id] }.each do |hi|
code = hi.hit[:id].to_s
bib = ItemData.new(
formattedref: Bib::Formattedref.new(content: code),
docidentifier: [Docidentifier.new(content: code, type: "IEC", primary: true)],
)
all_parts_item.relation << Relation.new(type: "partOf", bibitem: bib)
end
all_parts_item
end
|