Sha256: 456ec125db440c6fed5416e068effaba98589a614ca37e59d91dbc123866605e
Contents?: true
Size: 1.08 KB
Versions: 21
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true require "net/http" module RelatonW3c # Class methods for search W3C standards. class W3cBibliography class << self # @param text [String] # @return [RelatonW3c::HitCollection] def search(text) HitCollection.new text rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Errno::ETIMEDOUT raise RelatonBib::RequestError, "Could not access #{HitCollection::DOMAIN}" end # @param ref [String] the W3C standard Code to look up # @param year [String, NilClass] not used # @param opts [Hash] options # @return [RelatonW3c::W3cBibliographicItem] def get(ref, _year = nil, _opts = {}) warn "[relaton-w3c] (\"#{ref}\") fetching..." result = search(ref) return unless result.any? ret = result.first.fetch warn "[relaton-w3c] (\"#{ref}\") found #{ret.title.first.title.content}" ret end end end end
Version data entries
21 entries across 21 versions & 2 rubygems