Class: RelatonNist::Hit
- Inherits:
-
RelatonBib::Hit
- Object
- RelatonBib::Hit
- RelatonNist::Hit
- Defined in:
- lib/relaton_nist/hit.rb
Overview
Hit.
Instance Attribute Summary collapse
-
#fetch ⇒ RelatonNist::NistBliographicItem
Parse page.
Instance Method Summary collapse
-
#sort_value ⇒ Iteger
Calculate sorting weigth of hit by series, code, title, addendum, and status.
Instance Attribute Details
#fetch ⇒ RelatonNist::NistBliographicItem
Parse page.
13 14 15 |
# File 'lib/relaton_nist/hit.rb', line 13 def fetch @fetch ||= Scrapper.parse_page @hit end |
Instance Method Details
#sort_value ⇒ Iteger
Calculate sorting weigth of hit by series, code, title, addendum, and status
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/relaton_nist/hit.rb', line 22 def sort_value # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity @sort_value ||= begin sort_phrase = [hit[:series], hit[:code], hit[:title]].join " " corr = hit_collection&.text&.split&.map do |w| if w =~ /\w+/ && sort_phrase =~ Regexp.new(Regexp.escape(w), Regexp::IGNORECASE) 1 else 0 end end&.sum.to_i corr + case hit[:status] when "final" then 4 when "withdrawn" then 3 when "draft" then 2 when "draft (obsolete)" then 1 else 0 end end end |