Class: TaliaCore::ActiveSourceParts::Xml::SourceBuilder

Inherits:
TaliaUtil::Xml::BaseBuilder show all
Defined in:
lib/talia_core/active_source_parts/xml/source_builder.rb

Overview

Class to build source representations of ActiveSource objects. Talia uses a simple XML format to encode the Source Object. The format maps easily to a Hash as it is used for the new or write_attributes methods:

<sources>
  <source>
    <attribute>
      <predicate>http://foobar/</predicate>
      <object>http://barbar/</object>
    </attribute>
    ...
  </source>
  <source>
    <attribute>
      <predicate>http://foobar/bar/</pedicate>
      <value>val</value>
      <object>http://some_url</object>
      <value>another</value>
      ...
    </attribute>
    ...
  </source>
  ...
</sources>

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TaliaUtil::Xml::BaseBuilder

make_xml_string, open

Class Method Details

.build_source(source) ⇒ Object



32
33
34
# File 'lib/talia_core/active_source_parts/xml/source_builder.rb', line 32

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 single source



37
38
39
40
41
42
# File 'lib/talia_core/active_source_parts/xml/source_builder.rb', line 37

def write_source(source)
  @builder.source do 
    source.attributes.each { |attrib, value| write_attribute(attrib, value) }
    source.direct_predicates.each { |pred| write_attribute(pred, source[pred]) } 
  end
end