Sha256: b10e5b6cedbc4f636824e509a1bdaddcca10d219b3068c17493d0726ca106871

Contents?: true

Size: 1.13 KB

Versions: 18

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module RelatonNist
  # Hit.
  class Hit < RelatonBib::Hit
    attr_writer :fetch

    #
    # Parse page.
    #
    # @return [RelatonNist::NistBliographicItem] bibliographic item
    #
    def fetch
      @fetch ||= Scrapper.parse_page @hit
    end

    #
    # Calculate sorting weigth of hit by series, code, title, addendum, and status
    #
    # @return [Iteger] sorting weigth
    #
    # def sort_value # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
    #   @sort_value ||= begin
    #     sort_phrase = [hit[:series], hit[:code]].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

18 entries across 18 versions & 1 rubygems

Version Path
relaton-nist-1.20.0 lib/relaton_nist/hit.rb
relaton-nist-1.19.7 lib/relaton_nist/hit.rb
relaton-nist-1.19.6 lib/relaton_nist/hit.rb
relaton-nist-1.19.5 lib/relaton_nist/hit.rb
relaton-nist-1.19.4 lib/relaton_nist/hit.rb
relaton-nist-1.19.3 lib/relaton_nist/hit.rb
relaton-nist-1.19.1 lib/relaton_nist/hit.rb
relaton-nist-1.19.0 lib/relaton_nist/hit.rb
relaton-nist-1.18.0 lib/relaton_nist/hit.rb
relaton-nist-1.17.0 lib/relaton_nist/hit.rb
relaton-nist-1.16.4 lib/relaton_nist/hit.rb
relaton-nist-1.16.3 lib/relaton_nist/hit.rb
relaton-nist-1.16.2 lib/relaton_nist/hit.rb
relaton-nist-1.16.1 lib/relaton_nist/hit.rb
relaton-nist-1.16.0 lib/relaton_nist/hit.rb
relaton-nist-1.14.9 lib/relaton_nist/hit.rb
relaton-nist-1.14.8 lib/relaton_nist/hit.rb
relaton-nist-1.14.7 lib/relaton_nist/hit.rb