Class: RelatonIec::HitCollection
- Inherits:
-
RelatonBib::HitCollection
- Object
- RelatonBib::HitCollection
- RelatonIec::HitCollection
- Defined in:
- lib/relaton_iec/hit_collection.rb
Overview
Page of hit collection.
Constant Summary collapse
- INDEX_FILE =
"index1.yaml"
Instance Method Summary collapse
-
#initialize(ref, year = nil) ⇒ HitCollection
constructor
A new instance of HitCollection.
- #to_all_parts(r_year) ⇒ RelatonIec::IecBibliographicItem
Constructor Details
#initialize(ref, year = nil) ⇒ HitCollection
Returns a new instance of HitCollection.
15 16 17 18 19 |
# File 'lib/relaton_iec/hit_collection.rb', line 15 def initialize(ref, year = nil) super ref, year @index = Relaton::Index.find_or_create :IEC, url: "#{Hit::GHURL}index1.zip" , file: INDEX_FILE @array = fetch_from_gh end |
Instance Method Details
#to_all_parts(r_year) ⇒ RelatonIec::IecBibliographicItem
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/relaton_iec/hit_collection.rb', line 22 def to_all_parts(r_year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity parts = @array.select { |h| h.part && h.hit[:code].match?(/^[\s\w-]+:#{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[:code] == hit.hit[:code] }.each do |hi| isobib = RelatonIec::IecBibliographicItem.new( formattedref: RelatonBib::FormattedRef.new(content: hi.hit[:code]), docid: [RelatonBib::DocumentIdentifier.new(id: hi.hit[:code], type: "IEC", primary: true)], ) all_parts_item.relation << RelatonBib::DocumentRelation.new(type: "partOf", bibitem: isobib) end all_parts_item end |