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_PLAIN, RDF::NTriples::Writer::ESCAPE_PLAIN_U

Constants included from Util::Logger

Util::Logger::IOWrapper

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_quotedTriple, #format_triple, #format_tripleTerm, #format_uri, #initialize, 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, #initialize, #node_id, open, options, #prefix, #prefixes, #prefixes=, #puts, #quoted, to_sym, #to_sym, #uri_for, #validate?, #write_comment, #write_epilogue, #write_prologue, #write_statement, #write_triple, #write_triples

Methods included from Util::Aliasing::LateBound

#alias_method

Methods included from Writable

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

Methods included from Util::Coercions

#coerce_statements

Constructor Details

This class inherits a constructor from RDF::NTriples::Writer

Instance Method Details

#format_quad(subject, predicate, object, graph_name, **options) ⇒ String

Returns the N-Triples representation of a triple.

Parameters:

Returns:

  • (String)


125
126
127
128
129
# File 'lib/rdf/nquads.rb', line 125

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

#format_statement(statement, **options) ⇒ String

Returns the N-Quads representation of a statement.

Parameters:

  • statement (RDF::Statement)
  • options (Hash{Symbol => Object})

    = ({})

Returns:

  • (String)

Since:

  • 0.4.0



112
113
114
# File 'lib/rdf/nquads.rb', line 112

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

#write_quad(subject, predicate, object, graph_name)

This method returns an undefined value.

Outputs the N-Quads representation of a statement.

Parameters:



101
102
103
# File 'lib/rdf/nquads.rb', line 101

def write_quad(subject, predicate, object, graph_name)
  puts format_quad(subject, predicate, object, graph_name, **@options)
end