Sha256: d4f2e4e032be219f525ef91581161671e047d749cd3d0075b7421449817317de

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal:true

require "relaton_ietf/scrapper"

module RelatonIetf
  # IETF bibliography module
  module IetfBibliography
    class << self
      # @param code [String] the ISO standard Code to look up (e..g "ISO 9000")
      # @return [RelatonIetf::IetfBibliographicItem]
      def search(text)
        Scrapper.scrape_page text
      end

      # @param code [String] the ISO standard Code to look up (e..g "ISO 9000")
      # @param year [String] the year the standard was published (optional)
      # @param opts [Hash] options; restricted to :all_parts if all-parts
      #   reference is required
      # @return [RelatonIetf::IetfBibliographicItem] Relaton of reference
      def get(code, _year = nil, _opts = {})
        Util.warn "(#{code}) Fetching from Relaton repository ..."
        result = search code
        if result
          docid = result.docidentifier.detect(&:primary) || result.docidentifier.first
          Util.warn "(#{code}) Found: `#{docid.id}`"
        else
          Util.warn "(#{code}) Not found."
        end
        result
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
relaton-ietf-1.18.0 lib/relaton_ietf/ietf_bibliography.rb
relaton-ietf-1.17.0 lib/relaton_ietf/ietf_bibliography.rb
relaton-ietf-1.16.2 lib/relaton_ietf/ietf_bibliography.rb