Class: RelatonXsf::Hit

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

Instance Method Summary collapse

Instance Method Details

#fetchObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/relaton_xsf/hit.rb', line 3

def fetch
  return @doc if @doc

  agent = Mechanize.new
  resp = agent.get hit[:url]
  hash = YAML.safe_load resp.body
  hash["fetched"] = Date.today.to_s
  @doc = BibliographicItem.from_hash hash
rescue StandardError => e
  raise RelatonBib::RequestError, e.message
end