Class: WCID::Hit

Inherits:
Object
  • Object
show all
Defined in:
lib/wcid/hit.rb

Overview

Conducting a search of the WorldCat Identities site returns a WCID::Hit object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(m) ⇒ Hit

Hit objects contain some potentially useful information, but of primary interest to me is the lccn which allows you to grab the authority record of a particular hit.



16
17
18
19
20
21
22
23
24
# File 'lib/wcid/hit.rb', line 16

def initialize m
  @score = m.attributes['score']
  @established_form = m.elements["establishedForm"].text if m.elements["establishedForm"]
  @uri = m.elements['uri'].text if m.elements['uri']
  @citation = m.elements['citation'].text if m.elements['citation']
  @lccn = m.elements['lccn'].text if m.elements['lccn']
  @pubdates = m.elements['pubDates'].text if m.elements['pubDates']
  @name_type = m.elements['nameType'].text if m.elements['nameType']
end

Instance Attribute Details

#citationObject (readonly)

Returns the value of attribute citation.



10
11
12
# File 'lib/wcid/hit.rb', line 10

def citation
  @citation
end

#established_formObject (readonly)

Returns the value of attribute established_form.



10
11
12
# File 'lib/wcid/hit.rb', line 10

def established_form
  @established_form
end

#lccnObject (readonly)

Returns the value of attribute lccn.



10
11
12
# File 'lib/wcid/hit.rb', line 10

def lccn
  @lccn
end

#name_typeObject (readonly)

Returns the value of attribute name_type.



10
11
12
# File 'lib/wcid/hit.rb', line 10

def name_type
  @name_type
end

#pubdatesObject (readonly)

Returns the value of attribute pubdates.



10
11
12
# File 'lib/wcid/hit.rb', line 10

def pubdates
  @pubdates
end

#scoreObject (readonly)

Returns the value of attribute score.



10
11
12
# File 'lib/wcid/hit.rb', line 10

def score
  @score
end

#uriObject (readonly)

Returns the value of attribute uri.



10
11
12
# File 'lib/wcid/hit.rb', line 10

def uri
  @uri
end

Instance Method Details

#get_lc_authObject

Given a WCID::Hit object it returns a single authority record as a MARC::Record object.



28
29
30
31
32
# File 'lib/wcid/hit.rb', line 28

def get_lc_auth
  src = Net::HTTP.get(URI.parse("http://errol.oclc.org/laf/#{self.lccn}.MarcXML"))
  record = MARC::XMLReader.new(StringIO.new(string=src)).to_a
  record = record[0]
end