Class: TaliaCore::ActiveSourceParts::Xml::RdfBuilder
- Inherits:
-
TaliaUtil::Xml::RdfBuilder
- Object
- TaliaUtil::Xml::BaseBuilder
- TaliaUtil::Xml::RdfBuilder
- TaliaCore::ActiveSourceParts::Xml::RdfBuilder
- Defined in:
- lib/talia_core/active_source_parts/xml/rdf_builder.rb
Overview
Class for creating xml-rdf Data from a source. See the parent class, TaliaUtil::Xml::RdfBuilder, for more information.
Class Method Summary collapse
-
.build_source(source) ⇒ Object
Builds the RDF for a source and returns the result as a string.
Instance Method Summary collapse
-
#write_source(source) ⇒ Object
Builds the RDF for a source.
Methods inherited from TaliaUtil::Xml::RdfBuilder
open_for_triples, #write_triple, #write_triples, xml_string_for_triples
Methods inherited from TaliaUtil::Xml::BaseBuilder
Class Method Details
.build_source(source) ⇒ Object
Builds the RDF for a source and returns the result as a string
10 11 12 |
# File 'lib/talia_core/active_source_parts/xml/rdf_builder.rb', line 10 def self.build_source(source) make_xml_string { |build| build.write_source(source) } end |
Instance Method Details
#write_source(source) ⇒ Object
Builds the RDF for a source. This will include both the “direct” predicates as well as the “inverse” (incoming predicates of a source)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/talia_core/active_source_parts/xml/rdf_builder.rb', line 16 def write_source(source) # The source is written as subject, with all the triples nested inside it. @builder.rdf :Description, 'rdf:about' => source.uri.to_s do # Element describing this resource # loop through the predicates source.direct_predicates.each do |predicate| write_predicate(predicate, source[predicate]) end end # Each of the inverse properties creates another subject entry, that just contains the one # triple relating it to the current source. (In this case, the subject and predicate entries # aren't merged any further) source.inverse_predicates.each do |predicate| source.inverse[predicate].each do |inverse_subject| @builder.rdf :Description, 'rdf:about' => inverse_subject do write_predicate(predicate, [source]) end end end end |