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 Attribute Summary collapse
-
#from_gh ⇒ Boolean
readonly
Whether the search was performed on GitHub.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#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.
13 14 15 16 |
# File 'lib/relaton_iso/hit_collection.rb', line 13 def initialize(text) super @from_gh = text.match?(/^ISO[\s\/](?:TC\s184\/SC\s?4|IEC\sDIR\s(?:\d|IEC|JTC))/) end |
Instance Attribute Details
#from_gh ⇒ Boolean (readonly)
Returns whether the search was performed on GitHub.
10 11 12 |
# File 'lib/relaton_iso/hit_collection.rb', line 10 def from_gh @from_gh end |
Instance Method Details
#fetch ⇒ Object
18 19 20 21 |
# File 'lib/relaton_iso/hit_collection.rb', line 18 def fetch @array = from_gh ? fetch_github : fetch_iso self end |
#to_all_parts(lang = nil) ⇒ RelatonIsoBib::IsoBibliographicItem?
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/relaton_iso/hit_collection.rb', line 25 def to_all_parts(lang = nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength # parts = @array.reject { |h| h.hit["docPart"]&.empty? } hit = @array.min_by { |h| h.pubid.part.to_i } 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| isobib = RelatonIsoBib::IsoBibliographicItem.new( formattedref: RelatonBib::FormattedRef.new(content: hi.pubid.to_s), ) all_parts_item.relation << RelatonBib::DocumentRelation.new( type: "instanceOf", bibitem: isobib, ) end all_parts_item end |