Sha256: 47ca19840b8a39c9e8f2534779ba63ee4d06845dba0a154543e5d80d88f47c8e
Contents?: true
Size: 981 Bytes
Versions: 20
Compression:
Stored size: 981 Bytes
Contents
# frozen_string_literal: true module RelatonNist # Hit. class Hit < RelatonBib::Hit attr_writer :fetch # Parse page. # @return [RelatonNist::NistBliographicItem] def fetch @fetch ||= Scrapper.parse_page @hit end # @return [Iteger] 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 end end
Version data entries
20 entries across 20 versions & 1 rubygems