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
- DOMAIN =
"https://webstore.iec.ch"
Instance Attribute Summary collapse
-
#part ⇒ Object
readonly
Returns the value of attribute part.
Instance Method Summary collapse
-
#initialize(ref, year = nil, part = nil) ⇒ HitCollection
constructor
A new instance of HitCollection.
- #to_all_parts ⇒ RelatonIec::IecBibliographicItem
Constructor Details
#initialize(ref, year = nil, part = nil) ⇒ HitCollection
Returns a new instance of HitCollection.
18 19 20 21 22 |
# File 'lib/relaton_iec/hit_collection.rb', line 18 def initialize(ref, year = nil, part = nil) super ref, year @part = part @array = ref ? hits(ref, year) : [] end |
Instance Attribute Details
#part ⇒ Object (readonly)
Returns the value of attribute part.
11 12 13 |
# File 'lib/relaton_iec/hit_collection.rb', line 11 def part @part end |
Instance Method Details
#to_all_parts ⇒ RelatonIec::IecBibliographicItem
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/relaton_iec/hit_collection.rb', line 25 def to_all_parts # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity parts = @array.reject { |h| h.part.nil? } hit = parts.min_by &:part 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 |