Class: RelatonIec::HitCollection
- Inherits:
-
RelatonBib::HitCollection
- Object
- RelatonBib::HitCollection
- RelatonIec::HitCollection
- Defined in:
- lib/relaton_iec/hit_collection.rb
Overview
Page of hit collection.
Instance Method Summary collapse
-
#initialize(pubid, exclude: [:year]) ⇒ HitCollection
constructor
A new instance of HitCollection.
- #to_all_parts(r_year) ⇒ RelatonIec::IecBibliographicItem
Constructor Details
#initialize(pubid, exclude: [:year]) ⇒ HitCollection
Returns a new instance of HitCollection.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/relaton_iec/hit_collection.rb', line 13 def initialize(pubid, exclude: [:year]) super pubid.to_s @pubid = pubid @exclude = exclude @index = Relaton::Index.find_or_create( :iec, url: "#{Hit::GHURL}#{INDEXFILE}.zip", file: "#{INDEXFILE}", pubid_class: Pubid::Iec::Identifier ) @array = fetch_from_index end |
Instance Method Details
#to_all_parts(r_year) ⇒ RelatonIec::IecBibliographicItem
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/relaton_iec/hit_collection.rb', line 25 def to_all_parts(r_year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity parts = @array.select { |h| h.part && (!r_year || h.hit[:pubid].year&.to_s == r_year) } hit = parts.min_by { |h| h.part.to_i } return @array.first&.fetch unless hit bibitem = hit.fetch all_parts_item = bibitem.to_all_parts parts.reject { |h| h.hit[:pubid] == hit.hit[:pubid] }.each do |hi| code = hi.hit[:pubid].to_s isobib = RelatonIec::IecBibliographicItem.new( formattedref: RelatonBib::FormattedRef.new(content: code), docid: [DocumentIdentifier.new(id: hi.hit[:pubid], type: "IEC", primary: true)], ) all_parts_item.relation << RelatonBib::DocumentRelation.new(type: "partOf", bibitem: isobib) end all_parts_item end |