summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2013-06-05 17:12:28 +0200
committergebele <gebele@in-silico.ch>2013-06-05 17:12:28 +0200
commit8301c07ca829aec51f44fbd29b70deb1ce97a0ef (patch)
treee3229fae830f9593d11d2a9377c64f405358d13c
parentadaafdbe008dd44f18fdc32474b0ca76bdd4ef24 (diff)
simplify RDF::Writer method
-rw-r--r--_posts/2013-06-05-simplify-rdfwriter-method.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/_posts/2013-06-05-simplify-rdfwriter-method.md b/_posts/2013-06-05-simplify-rdfwriter-method.md
new file mode 100644
index 0000000..6ebe9a3
--- /dev/null
+++ b/_posts/2013-06-05-simplify-rdfwriter-method.md
@@ -0,0 +1,30 @@
+---
+layout: post
+title: "simplify RDF::Writer method"
+description: ""
+category: "Development"
+tags: ["RDF"]
+---
+{% include JB/setup %}
+
+Simplify the RDF::Writer method if you have already an rdf graph like:
+
+ @rdf = RDF::Graph.new
+ RDF::Reader.for(format).new(rdf) do |reader|
+ reader.each_statement{ |statement| @rdf << statement }
+ end
+
+To parse it to another format simpy use:
+
+ RDF::Writer.for(format).buffer(:encoding => Encoding::ASCII) do |writer|
+ writer << @rdf
+ end
+
+instead of:
+
+ RDF::Writer.for(format).buffer(:encoding => Encoding::ASCII) do |writer|
+ @rdf.each{|statement| writer << statement}
+ end
+
+and use the base class RDF::Writer instead of subclasses like RDF::Turtle::Writer.
+It is much more time-efficient !