Sha256: 0d0826493e1775e5fd84eb06719b8a04abcb5303b3c672c574f01294f1f15f3e
Contents?: true
Size: 921 Bytes
Versions: 2
Compression:
Stored size: 921 Bytes
Contents
# frozen_string_literal: true module RelatonNist # Hit. class Hit < RelatonBib::Hit # @return [RelatonNist::HitCollection] attr_reader :hit_collection # Parse page. # @return [RelatonNist::NistBliographicItem] def fetch @fetch ||= Scrapper.parse_page @hit end # @return [Iteger] def sort_value @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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
relaton-nist-0.7.0 | lib/relaton_nist/hit.rb |
relaton-nist-0.6.0 | lib/relaton_nist/hit.rb |