Class: Marc2LinkedData::OclcResource
- Inherits:
-
Resource
- Object
- Resource
- Marc2LinkedData::OclcResource
show all
- Defined in:
- lib/marc2linkeddata/oclc_resource.rb
Constant Summary
collapse
- PREFIX =
'http://www.worldcat.org/oclc/'
Instance Attribute Summary
Attributes inherited from Resource
#iri
Instance Method Summary
collapse
Methods inherited from Resource
#get_rdf, #id, #iri_types, #rdf_find_object, #rdf_find_subject, #rdf_uri, #rdf_valid?, #resolve_external_auth, #same_as, #same_as_array
Constructor Details
#initialize(uri = nil) ⇒ OclcResource
Returns a new instance of OclcResource.
9
10
11
12
13
14
15
|
# File 'lib/marc2linkeddata/oclc_resource.rb', line 9
def initialize(uri=nil)
unless uri =~ /www\./
uri = uri.to_s.gsub('worldcat.org','www.worldcat.org')
end
super(uri)
end
|
Instance Method Details
#about ⇒ Object
47
48
49
50
|
# 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? ⇒ Boolean
27
28
29
|
# 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) ⇒ Boolean
35
36
37
|
# File 'lib/marc2linkeddata/oclc_resource.rb', line 35
def contributor?(uri)
contributors.include? RDF::URI.new(uri)
end
|
#contributors ⇒ Object
57
58
59
60
|
# 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) ⇒ Boolean
31
32
33
|
# File 'lib/marc2linkeddata/oclc_resource.rb', line 31
def creator?(uri)
creators.include? RDF::URI.new(uri)
end
|
#creators ⇒ Object
52
53
54
55
|
# 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) ⇒ Boolean
39
40
41
|
# File 'lib/marc2linkeddata/oclc_resource.rb', line 39
def editor?(uri)
editors.include? RDF::URI.new(uri)
end
|
#editors ⇒ Object
62
63
64
65
|
# 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 ⇒ Object
72
73
74
75
|
# 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
|
43
44
45
|
# 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 ⇒ Object
67
68
69
70
|
# 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 ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/marc2linkeddata/oclc_resource.rb', line 17
def rdf
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
|