Class: RDF::Normalize::Writer
- Inherits:
-
RDF::NQuads::Writer
- Object
- Writer
- RDF::NTriples::Writer
- RDF::NQuads::Writer
- RDF::Normalize::Writer
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/writer.rb
Overview
A RDF Graph normalization serialiser.
Normalizes the enumerated statements into normal form in the form of N-Quads.
Constant Summary
Constants inherited from RDF::NTriples::Writer
RDF::NTriples::Writer::ESCAPE_PLAIN, RDF::NTriples::Writer::ESCAPE_PLAIN_U
Constants included from Util::Logger
Instance Attribute Summary collapse
-
#repo ⇒ RDF::Repository
Repository of statements to serialized.
Attributes inherited from Writer
Instance Method Summary collapse
-
#initialize(output = $stdout, **options) {|writer| ... } ⇒ Writer
constructor
Initializes the writer instance.
-
#insert_statements(enumerable)
protected
Insert an Enumerable.
-
#write_epilogue
Outputs the Graph representation of all stored triples.
-
#write_quad(subject, predicate, object, graph_name)
Adds statements to the repository to be serialized in epilogue.
Methods inherited from RDF::NQuads::Writer
#format_quad, #format_statement
Methods inherited from RDF::NTriples::Writer
escape, escape_ascii, escape_unicode, escape_utf16, escape_utf32, #format_literal, #format_node, #format_quotedTriple, #format_statement, #format_triple, #format_tripleTerm, #format_uri, serialize, #write_comment, #write_triple
Methods included from Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
Methods inherited from Writer
accept?, #base_uri, buffer, #canonicalize?, dump, each, #encoding, #escaped, #flush, for, format, #format_list, #format_literal, #format_node, #format_quotedTriple, #format_term, #format_tripleTerm, #format_uri, #node_id, open, options, #prefix, #prefixes, #prefixes=, #puts, #quoted, #to_sym, to_sym, #uri_for, #validate?, #write_comment, #write_prologue, #write_statement, #write_triple, #write_triples
Methods included from Util::Aliasing::LateBound
Methods included from Writable
#<<, #insert, #insert_graph, #insert_reader, #insert_statement, #writable?
Methods included from Util::Coercions
Constructor Details
#initialize(output = $stdout, **options) {|writer| ... } ⇒ Writer
Initializes the writer instance.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/writer.rb', line 26 def initialize(output = $stdout, **, &block) super do @repo = RDF::Repository.new if block_given? case block.arity when 0 then instance_eval(&block) else block.call(self) end end end end |
Instance Attribute Details
#repo ⇒ RDF::Repository
Returns Repository of statements to serialized.
12 13 14 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/writer.rb', line 12 def repo @repo end |
Instance Method Details
#insert_statements(enumerable) (protected)
This method returns an undefined value.
Insert an Enumerable
74 75 76 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/writer.rb', line 74 def insert_statements(enumerable) @repo = enumerable end |
#write_epilogue
This method returns an undefined value.
Outputs the Graph representation of all stored triples.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/writer.rb', line 55 def write_epilogue RDF::Normalize.new(@repo, **@options). statements. reject(&:variable?). map {|s| format_statement(s)}. sort. each do |line| puts line end super end |
#write_quad(subject, predicate, object, graph_name)
This method returns an undefined value.
Adds statements to the repository to be serialized in epilogue.
47 48 49 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-normalize-5170ab39c807/lib/rdf/normalize/writer.rb', line 47 def write_quad(subject, predicate, object, graph_name) @repo.insert(RDF::Statement(subject, predicate, object, graph_name: graph_name)) end |