Module: OpenAnnotationHarvest
- Defined in:
- lib/annotations2triannon/open_annotation_harvest.rb
Overview
Module designed to be a mixin for manifest and annotation list. The methods assume that the class including this module contains an #rdf method to access and RDF::Graph object.
Instance Method Summary collapse
-
#collect_open_annotations ⇒ Array<RDF::Graph>
Searches rdf graph to find RDF::Vocab::OA.Annotation.
-
#rdf_subject_graph(subject) ⇒ RDF::Graph
Graph for ‘subject’ as the ?s in ?s ?p ?o.
Instance Method Details
#collect_open_annotations ⇒ Array<RDF::Graph>
Searches rdf graph to find RDF::Vocab::OA.Annotation
9 10 11 12 13 14 15 16 17 |
# File 'lib/annotations2triannon/open_annotation_harvest.rb', line 9 def collect_open_annotations oa_graphs = [] q = [nil, RDF.type, RDF::Vocab::OA.Annotation] # 'rdf' must be a method to access an RDF::Graph object rdf.query(q).each_subject do |s| oa_graphs << rdf_subject_graph(s) end oa_graphs end |
#rdf_subject_graph(subject) ⇒ RDF::Graph
Returns graph for ‘subject’ as the ?s in ?s ?p ?o.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/annotations2triannon/open_annotation_harvest.rb', line 21 def rdf_subject_graph(subject) g = RDF::Graph.new # 'rdf' must be a method to access an RDF::Graph object rdf.query([subject, nil, nil]) do |s,p,o| g << [s,p,o] g << rdf_subject_graph(o) if o.node? g << rdf_subject_graph(o) if o.uri? end g end |