Class: RelatonIso::HitCollection
- Inherits:
-
RelatonBib::HitCollection
- Object
- RelatonBib::HitCollection
- RelatonIso::HitCollection
- Defined in:
- lib/relaton_iso/hit_collection.rb
Overview
Page of hit collection.
Instance Method Summary collapse
-
#initialize(text) ⇒ HitCollection
constructor
A new instance of HitCollection.
- #to_all_parts(lang = nil) ⇒ RelatonIsoBib::IsoBibliographicItem
Constructor Details
#initialize(text) ⇒ HitCollection
Returns a new instance of HitCollection.
12 13 14 15 |
# File 'lib/relaton_iso/hit_collection.rb', line 12 def initialize(text) super @array = text.match?(/^ISO\sTC\s184\/SC\s?4/) ? fetch_github : fetch_iso end |
Instance Method Details
#to_all_parts(lang = nil) ⇒ RelatonIsoBib::IsoBibliographicItem
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/relaton_iso/hit_collection.rb', line 19 def to_all_parts(lang = nil) # rubocop:disable Metrics/CyclomaticComplexity # parts = @array.reject { |h| h.hit["docPart"]&.empty? } hit = @array.min_by do |h| IsoBibliography.ref_components(h.hit[:title])[1].to_i end return @array.first.fetch lang unless hit bibitem = hit.fetch lang all_parts_item = bibitem.to_all_parts @array.reject { |h| h.hit[:uuid] == hit.hit[:uuid] }.each do |hi| %r{^(?<fr>ISO(?:\s|/)[^-/:()]+(?:-[\w-]+)?(?::\d{4})? (?:/\w+(?:\s\w+)?\s\d+(?:\d{4})?)?)}x =~ hi.hit[:title] isobib = RelatonIsoBib::IsoBibliographicItem.new( formattedref: RelatonBib::FormattedRef.new(content: fr), ) all_parts_item.relation << RelatonBib::DocumentRelation.new( type: "instance", bibitem: isobib, ) end all_parts_item end |