summaryrefslogtreecommitdiff
path: root/_posts/2013-06-05-simplify-rdfwriter-method.md
diff options
context:
space:
mode:
Diffstat (limited to '_posts/2013-06-05-simplify-rdfwriter-method.md')
-rw-r--r--_posts/2013-06-05-simplify-rdfwriter-method.md6
1 files changed, 6 insertions, 0 deletions
diff --git a/_posts/2013-06-05-simplify-rdfwriter-method.md b/_posts/2013-06-05-simplify-rdfwriter-method.md
index db06731..c1c3f01 100644
--- a/_posts/2013-06-05-simplify-rdfwriter-method.md
+++ b/_posts/2013-06-05-simplify-rdfwriter-method.md
@@ -9,19 +9,25 @@ tags: ["RDF"]
Simplify the RDF::Writer method if you have already an rdf graph like:
+```ruby
@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 simply use:
+```ruby
RDF::Writer.for(format).buffer(:encoding => Encoding::ASCII) do |writer|
writer << @rdf
end
+```
instead of:
+```ruby
RDF::Writer.for(format).buffer(:encoding => Encoding::ASCII) do |writer|
@rdf.each{|statement| writer << statement}
end
+``` \ No newline at end of file