Class: RelatonIec::Hit

Inherits:
RelatonBib::Hit
  • Object
show all
Defined in:
lib/relaton_iec/hit.rb

Overview

Hit.

Constant Summary collapse

GHURL =
"https://raw.githubusercontent.com/relaton/relaton-data-iec/main/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fetchRelatonIec::IecBibliographicItem

Parse page.



12
13
14
15
16
17
18
19
20
# File 'lib/relaton_iec/hit.rb', line 12

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

Instance Method Details

#partObject



22
23
24
# File 'lib/relaton_iec/hit.rb', line 22

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