class Marc2LinkedData::OclcResource

Constants

PREFIX

Public Class Methods

new(uri=nil) click to toggle source
Calls superclass method
# File lib/marc2linkeddata/oclc_resource.rb, line 9
def initialize(uri=nil)
  # Ensure the OCLC IRI contains 'www' in the host name.
  unless uri =~ /www\./
    uri = uri.to_s.gsub('worldcat.org','www.worldcat.org')
  end
  super(uri)
end

Public Instance Methods

about() click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 47
def about
  q = SPARQL.parse('SELECT * WHERE { ?s <http://schema.org/about> ?o }')
  rdf.query(q)
end
book?() click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 27
def book?
  iri_types.filter {|s| s[:o] == 'http://schema.org/Book' }.length > 0
end
contributor?(uri) click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 35
def contributor?(uri)
  contributors.include? RDF::URI.new(uri)
end
contributors() click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 57
def contributors
  q = SPARQL.parse("SELECT * WHERE { <#{@iri}> <http://schema.org/contributor> ?o }")
  rdf.query(q).collect {|s| s[:o] }
end
creator?(uri) click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 31
def creator?(uri)
  creators.include? RDF::URI.new(uri)
end
creators() click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 52
def creators
  q = SPARQL.parse("SELECT * WHERE { <#{@iri}> <http://schema.org/creator> ?o }")
  rdf.query(q).collect {|s| s[:o] }
end
editor?(uri) click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 39
def editor?(uri)
  editors.include? RDF::URI.new(uri)
end
editors() click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 62
def editors
  q = SPARQL.parse("SELECT * WHERE { <#{@iri}> <http://schema.org/editor> ?o }")
  rdf.query(q).collect {|s| s[:o] }
end
isbns() click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 72
def isbns
  q = SPARQL.parse("SELECT * WHERE { <#{@iri}> <http://schema.org/isbn> ?o }")
  rdf.query(q).collect {|s| s[:o] }
end
media_object?() click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 43
def media_object?
  iri_types.filter {|s| s[:o] == 'http://schema.org/MediaObject' }.length > 0
end
publishers() click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 67
def publishers
  q = SPARQL.parse("SELECT * WHERE { <#{@iri}> <http://schema.org/publisher> ?o }")
  rdf.query(q).collect {|s| s[:o] }
end
rdf() click to toggle source
# File lib/marc2linkeddata/oclc_resource.rb, line 17
def rdf
  # e.g. 'http://worldcat.org/oclc/004957186'
  # also 'http://www.worldcat.org/oclc/004957186'
  return nil if @iri.nil?
  return @rdf unless @rdf.nil?
  uri4rdf = @iri.to_s
  uri4rdf += '.rdf' unless uri4rdf.end_with? '.rdf'
  @rdf = get_rdf(uri4rdf)
end