Class: Relaton::Xsf::Hit

Inherits:
Core::Hit
  • Object
show all
Defined in:
lib/relaton/xsf/hit.rb

Instance Method Summary collapse

Instance Method Details

#itemObject



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

def item
  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 = Relaton::Xsf::Item.from_yaml hash.to_yaml
rescue StandardError => e
  raise Relaton::RequestError, e.message
end