Sha256: 8e681091e1808cf0aeb9713cfbdbd242c7bed9fe67bc5c6c5f3c7c29c5b329cd

Contents?: true

Size: 598 Bytes

Versions: 1

Compression:

Stored size: 598 Bytes

Contents

# frozen_string_literal: true

module RelatonIec
  # Hit.
  class Hit < RelatonBib::Hit
    GHURL = "https://raw.githubusercontent.com/relaton/relaton-data-iec/main/"

    attr_writer :fetch

    # Parse page.
    # @return [RelatonIec::IecBibliographicItem]
    def fetch
      @fetch ||= begin
        url = "#{GHURL}#{hit[:file]}"
        resp = Net::HTTP.get URI(url)
        hash = YAML.safe_load resp
        hash["fetched"] = Date.today.to_s
        IecBibliographicItem.from_hash hash
      end
    end

    def part
      @part ||= hit[:code].match(/(?<=-)[\w-]+/)&.to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-iec-1.14.2 lib/relaton_iec/hit.rb