Class: Relaton::Iec::HitCollection
- Inherits:
-
Core::HitCollection
- Object
- Core::HitCollection
- Relaton::Iec::HitCollection
- Defined in:
- lib/relaton/iec/hit_collection.rb
Overview
Page of hit collection.
Instance Attribute Summary
Attributes inherited from Core::HitCollection
Instance Method Summary collapse
Methods inherited from Core::HitCollection
#fetch, #initialize, #inspect, #reduce!, #select, #select!, #to_s, #to_xml
Constructor Details
This class inherits a constructor from Relaton::Core::HitCollection
Instance Method Details
#search(exclude: [:year]) ⇒ Object
13 14 15 16 |
# File 'lib/relaton/iec/hit_collection.rb', line 13 def search(exclude: [:year]) @array = fetch_from_index exclude self end |
#to_all_parts(r_year, opts = {}) ⇒ Relaton::Iec::ItemData?
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/relaton/iec/hit_collection.rb', line 19 def to_all_parts(r_year, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity parts = @array.select { |h| h.part && (!r_year || h.hit[:id]&.date&.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].date&.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 others = parts.reject { |h| h.hit[:id] == hit.hit[:id] } others.sort_by { |h| part_sort_key(h.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 |