Class: RDF::Oxigraph::Writer

Inherits:
Writer
  • Object
show all
Defined in:
lib/rdf/oxigraph/format.rb

Overview

Batch RDF::Writer backed by oxigraph's native serializers. Buffers statements and serializes once on epilogue. Subclasses set oxigraph_format.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output = $stdout, **options, &block) ⇒ Writer

Returns a new instance of Writer.



58
59
60
61
# File 'lib/rdf/oxigraph/format.rb', line 58

def initialize(output = $stdout, **options, &block)
  @quads = []
  super
end

Class Method Details

.oxigraph_format(value = nil) ⇒ Object



53
54
55
56
# File 'lib/rdf/oxigraph/format.rb', line 53

def self.oxigraph_format(value = nil)
  @oxigraph_format = value unless value.nil?
  @oxigraph_format
end

Instance Method Details

#write_epilogueObject



72
73
74
75
# File 'lib/rdf/oxigraph/format.rb', line 72

def write_epilogue
  @output.write(RDF::Oxigraph.serialize(@quads, self.class.oxigraph_format))
  super
end

#write_statement(statement) ⇒ Object



63
64
65
66
# File 'lib/rdf/oxigraph/format.rb', line 63

def write_statement(statement)
  @quads << Conversion.serialize_statement(statement)
  statement
end

#write_triple(subject, predicate, object) ⇒ Object



68
69
70
# File 'lib/rdf/oxigraph/format.rb', line 68

def write_triple(subject, predicate, object)
  write_statement(RDF::Statement.new(subject, predicate, object))
end