Class: Marc2LinkedData::Viaf
- Defined in:
- lib/marc2linkeddata/viaf.rb
Constant Summary collapse
- PREFIX =
'http://viaf.org/viaf/'
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
- #family_names ⇒ Object
- #get_isni ⇒ Object
- #given_names ⇒ Object
-
#rdf ⇒ Object
def id return nil if @iri.nil? iri.path.gsub(‘viaf/’,”).gsub(‘/’,”) end.
Methods inherited from Resource
#get_rdf, #id, #initialize, #iri_types, #rdf_find_object, #rdf_find_subject, #rdf_uri, #rdf_valid?, #resolve_external_auth, #same_as, #same_as_array
Constructor Details
This class inherits a constructor from Marc2LinkedData::Resource
Instance Method Details
#family_names ⇒ Object
39 40 41 42 43 |
# File 'lib/marc2linkeddata/viaf.rb', line 39 def family_names q = SPARQL.parse("SELECT * WHERE { <#{@iri}> <http://schema.org/familyName> ?o }") names = rdf.query(q).collect {|s| s[:o].to_s} names.to_set.to_a end |
#get_isni ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/marc2linkeddata/viaf.rb', line 21 def get_isni return nil if @iri.nil? return nil unless rdf_valid? return @isni_iri unless @isni_iri.nil? # Try to get ISNI source for VIAF # e.g. http://viaf.org/viaf/sourceID/ISNI%7C0000000109311081#skos:Concept isni_iri = rdf_find_subject 'isni' isni_src = URI.parse(isni_iri.to_s) isni_iri = isni_src.path.sub('/viaf/sourceID/ISNI%7C','http://www.isni.org/isni/') @isni_iri = resolve_external_auth(isni_iri) end |
#given_names ⇒ Object
33 34 35 36 37 |
# File 'lib/marc2linkeddata/viaf.rb', line 33 def given_names q = SPARQL.parse("SELECT * WHERE { <#{@iri}> <http://schema.org/givenName> ?o }") names = rdf.query(q).collect {|s| s[:o].to_s} names.to_set.to_a end |
#rdf ⇒ Object
def id
return nil if @iri.nil?
iri.path.gsub('viaf/','').gsub('/','')
end
14 15 16 17 18 19 |
# File 'lib/marc2linkeddata/viaf.rb', line 14 def rdf return nil if @iri.nil? return @rdf unless @rdf.nil? uri4rdf = @iri.to_s + '/rdf.xml' @rdf = get_rdf(uri4rdf) end |