Class: RDF::NQuads::Writer

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

Overview

Reader

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, #escaped, #format_literal, #format_node, #format_triple, #format_uri, serialize, #write_comment, #write_triple

Methods inherited from Writer

#base_uri, buffer, dump, each, #flush, for, format, #format_list, #format_literal, #format_node, #format_term, #format_uri, #initialize, open, #prefix, #prefixes, #prefixes=, to_sym, #to_sym, #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, #writable?

Constructor Details

This class inherits a constructor from RDF::Writer

Instance Method Details

#format_quad(subject, predicate, object, context) ⇒ String

Returns the N-Triples representation of a triple.

Parameters:

Returns:

  • (String)


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

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

#format_statement(statement) ⇒ String

Returns the N-Quads representation of a statement.

Parameters:

Returns:

  • (String)

Since:

  • 0.4.0



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

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

#write_quad(subject, predicate, object, context) ⇒ void

This method returns an undefined value.

Outputs the N-Quads representation of a statement.

Parameters:



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

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

#write_statement(statement) ⇒ void Also known as: insert_statement

This method returns an undefined value.

Returns ‘self`.

Parameters:



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

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