Class: Rialto::Etl::Writers::NtriplesWriter
- Inherits:
-
Traject::LineWriter
- Object
- Traject::LineWriter
- Rialto::Etl::Writers::NtriplesWriter
- Defined in:
- lib/rialto/etl/writers/ntriples_writer.rb
Overview
Write NTriples records
Instance Method Summary collapse
-
#serialize(context) ⇒ String
Overrides the serialization routine from superclass.
Instance Method Details
#serialize(context) ⇒ String
Overrides the serialization routine from superclass
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rialto/etl/writers/ntriples_writer.rb', line 17 def serialize(context) hash = context.output_hash subject = RDF::URI.new(hash.delete('@id')) type = RDF::URI.new(hash.delete('@type')) graph = RDF::Graph.new << [subject, RDF.type, type] hash.each_pair do |field, values| Array(values).each do |value| graph << [subject, RDF::URI.new(field), value] end end graph.dump(:ntriples) end |