class RelatonNist::Hit

Hit.

Attributes

fetch[W]

Public Instance Methods

fetch() click to toggle source

Parse page. @return [RelatonNist::NistBliographicItem]

# File lib/relaton_nist/hit.rb, line 10
def fetch
  @fetch ||= Scrapper.parse_page @hit
end
sort_value() click to toggle source

@return [Iteger]

# File lib/relaton_nist/hit.rb, line 15
def sort_value # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
  @sort_value ||= begin
    sort_phrase = [hit[:serie], 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