Class: Relaton::Iec::Hit

Inherits:
Core::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/refs/heads/data-v2/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#itemRelaton::Iec::ItemData

Parse page.



13
14
15
16
17
18
19
# File 'lib/relaton/iec/hit.rb', line 13

def item
  @item ||= begin
    url = "#{GHURL}#{hit[:file]}"
    resp = Net::HTTP.get URI(url)
    Item.from_yaml(resp).tap { |it| it.fetched = Date.today.to_s }
  end
end

Instance Method Details

#partObject



21
22
23
# File 'lib/relaton/iec/hit.rb', line 21

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