Class: WCID::Hit
- Inherits:
-
Object
- Object
- WCID::Hit
- Defined in:
- lib/wcid/hit.rb
Overview
Conducting a search of the WorldCat Identities site returns a WCID::Hit object.
Instance Attribute Summary collapse
-
#citation ⇒ Object
readonly
Returns the value of attribute citation.
-
#established_form ⇒ Object
readonly
Returns the value of attribute established_form.
-
#lccn ⇒ Object
readonly
Returns the value of attribute lccn.
-
#name_type ⇒ Object
readonly
Returns the value of attribute name_type.
-
#pubdates ⇒ Object
readonly
Returns the value of attribute pubdates.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#get_lc_auth ⇒ Object
Given a WCID::Hit object it returns a single authority record as a MARC::Record object.
-
#initialize(m) ⇒ Hit
constructor
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.
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
#citation ⇒ Object (readonly)
Returns the value of attribute citation.
10 11 12 |
# File 'lib/wcid/hit.rb', line 10 def citation @citation end |
#established_form ⇒ Object (readonly)
Returns the value of attribute established_form.
10 11 12 |
# File 'lib/wcid/hit.rb', line 10 def established_form @established_form end |
#lccn ⇒ Object (readonly)
Returns the value of attribute lccn.
10 11 12 |
# File 'lib/wcid/hit.rb', line 10 def lccn @lccn end |
#name_type ⇒ Object (readonly)
Returns the value of attribute name_type.
10 11 12 |
# File 'lib/wcid/hit.rb', line 10 def name_type @name_type end |
#pubdates ⇒ Object (readonly)
Returns the value of attribute pubdates.
10 11 12 |
# File 'lib/wcid/hit.rb', line 10 def pubdates @pubdates end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
10 11 12 |
# File 'lib/wcid/hit.rb', line 10 def score @score end |
#uri ⇒ Object (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_auth ⇒ Object
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 |