Class: RDF::Normalize::Writer
- Inherits:
-
RDF::NQuads::Writer
- Object
- RDF::NQuads::Writer
- RDF::Normalize::Writer
- Defined in:
- lib/rdf/normalize/writer.rb
Overview
A RDF Graph normalization serialiser.
Normalizes the enumerated statements into normal form in the form of N-Quads.
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
Instance Method Summary collapse
-
#initialize(output = $stdout, options = {}) {|writer| ... } ⇒ Writer
constructor
Initializes the writer instance.
-
#write_epilogue ⇒ void
Outputs the Graph representation of all stored triples.
-
#write_statement(statement) ⇒ Object
Defer writing to epilogue.
Constructor Details
#initialize(output = $stdout, options = {}) {|writer| ... } ⇒ Writer
Initializes the writer instance.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rdf/normalize/writer.rb', line 26 def initialize(output = $stdout, = {}, &block) super do [:depth] ||= 0 @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 ⇒ Object
Returns the value of attribute repo.
12 13 14 |
# File 'lib/rdf/normalize/writer.rb', line 12 def repo @repo end |
Instance Method Details
#write_epilogue ⇒ void
This method returns an undefined value.
Outputs the Graph representation of all stored triples.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rdf/normalize/writer.rb', line 49 def write_epilogue statements = RDF::Normalize.new(@repo, ). statements. reject(&:variable?). map {|s| format_statement(s)}. sort. each do |line| puts line end end |
#write_statement(statement) ⇒ Object
Defer writing to epilogue
41 42 43 |
# File 'lib/rdf/normalize/writer.rb', line 41 def write_statement(statement) self end |