Sha256: 38fe64b182276644513ff18dbdc69c23d740eabaff849d26ee3a5be96deb39b6
Contents?: true
Size: 1.48 KB
Versions: 8
Compression:
Stored size: 1.48 KB
Contents
require 'rdf/turtle/terminals' module RDF::Turtle ## # Streaming writer interface # @author [Gregg Kellogg](http://greggkellogg.net/) module StreamingWriter ## # Write out declarations # @return [void] `self` def stream_prologue if @options[:standard_prefixes] RDF::Vocabulary.each do |vocab| pfx = vocab.__name__.to_s.split('::').last.downcase prefix(pfx, vocab.to_uri) end end preprocess start_document @output.puts "" end ## # Write out a statement, retaining current # `subject` and `predicate` to create more compact output # @return [void] `self` def stream_statement(statement) if statement.subject != @streaming_subject @output.puts ' .' if @streaming_subject @streaming_subject, @streaming_predicate = statement.subject, statement.predicate @output.write "#{format_term(statement.subject, options)} " @output.write "#{format_term(statement.predicate, options)} " elsif statement.predicate != @streaming_predicate @streaming_predicate = statement.predicate @output.write ";\n#{indent(1)}#{format_term(statement.predicate, options)} " else @output.write ",\n#{indent(2)}" end @output.write("#{format_term(statement.object, options)}") end ## # Complete open statements # @return [void] `self` def stream_epilogue @output.puts ' .' if @streaming_subject end private end end
Version data entries
8 entries across 8 versions & 1 rubygems