Class: RDF::NQuads::Writer

Inherits:
RDF::NTriples::Writer show all
Defined in:
lib/rdf/nquads.rb

Overview

Reader

Constant Summary

Constant Summary

Constants inherited from RDF::NTriples::Writer

RDF::NTriples::Writer::ESCAPE_ASCII, RDF::NTriples::Writer::ESCAPE_PLAIN

Instance Attribute Summary

Attributes inherited from Writer

#options

Instance Method Summary (collapse)

Methods inherited from RDF::NTriples::Writer

escape, escape_ascii, escape_unicode, escape_utf16, escape_utf32, #format_literal, #format_node, #format_triple, #format_uri, serialize, #write_comment, #write_triple

Methods inherited from Writer

#base_uri, buffer, dump, each, #escaped, #flush, for, format, #format_list, #format_literal, #format_node, #format_term, #format_uri, #initialize, #node_id, open, #prefix, #prefixes, #prefixes=, #puts, #quoted, #to_sym, to_sym, #uri_for, #write_comment, #write_epilogue, #write_graph, #write_prologue, #write_statements, #write_triple, #write_triples

Methods included from Util::Aliasing::LateBound

#alias_method

Methods included from Writable

#<<, #insert, #insert_graph, #insert_reader, #insert_statements, #writable?

Constructor Details

This class inherits a constructor from RDF::Writer

Instance Method Details

- (String) format_quad(subject, predicate, object, context)

Returns the N-Triples representation of a triple.

Parameters:

Returns:

  • (String)


127
128
129
130
131
# File 'lib/rdf/nquads.rb', line 127

def format_quad(subject, predicate, object, context)
  s = "%s %s %s " % [subject, predicate, object].map { |value| format_term(value) }
  s += format_term(context) + " " if context
  s + "."
end

- (String) format_statement(statement)

Returns the N-Quads representation of a statement.

Parameters:

Returns:

  • (String)

Since:

  • 0.4.0



115
116
117
# File 'lib/rdf/nquads.rb', line 115

def format_statement(statement)
  format_quad(*statement.to_quad)
end

- write_quad(subject, predicate, object, context)

This method returns an undefined value.

Outputs the N-Quads representation of a statement.

Parameters:



105
106
107
# File 'lib/rdf/nquads.rb', line 105

def write_quad(subject, predicate, object, context)
  puts format_quad(subject, predicate, object, context)
end

- write_statement(statement) Also known as: insert_statement

This method returns an undefined value.

self

Parameters:



92
93
94
95
# File 'lib/rdf/nquads.rb', line 92

def write_statement(statement)
  write_quad(*statement.to_quad)
  self
end