Class: RelatonIec::Hit
- Inherits:
-
RelatonBib::Hit
- Object
- RelatonBib::Hit
- RelatonIec::Hit
- 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
-
#fetch ⇒ RelatonIec::IecBibliographicItem
Parse page.
Instance Method Summary collapse
Instance Attribute Details
#fetch ⇒ RelatonIec::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
#inspect ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/relaton_iec/hit.rb', line 26 def inspect "<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)} " \ "@text=\"#{@hit_collection&.text}\" " \ "@fetched=\"#{!@fetch.nil?}\" " \ "@fullIdentifier=\"#{@fetch&.shortref(nil, no_year: true)}\" " \ "@title=\"#{@hit[:code]}\">" end |
#part ⇒ Object
22 23 24 |
# File 'lib/relaton_iec/hit.rb', line 22 def part @part ||= hit[:code].match(/(?<=-)[\w-]+/)&.to_s end |