Module: RDF::NTriples

Included in:
NQuads
Defined in:
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-237066655558/lib/rdf/ntriples.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-237066655558/lib/rdf/ntriples/format.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-237066655558/lib/rdf/ntriples/reader.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-237066655558/lib/rdf/ntriples/writer.rb

Overview

RDF::NTriples provides support for the N-Triples serialization format.

N-Triples is a line-based plain-text format for encoding an RDF graph. It is a very restricted, explicit and well-defined subset of both Turtle and Notation3 (N3).

The MIME content type for N-Triples files is text/plain and the recommended file extension is .nt.

An example of an RDF statement in N-Triples format:

<https://rubygems.org/gems/rdf> <http://purl.org/dc/terms/title> "rdf" .

RDFStar (RDF*)

Supports statements as resources using <<s p o>>.

Installation

This is the only RDF serialization format that is directly supported by RDF.rb. Support for other formats is available in the form of add-on gems, e.g. 'rdf-xml' or 'rdf-json'.

Documentation

Examples:

Requiring the RDF::NTriples module explicitly

require 'rdf/ntriples'

See Also:

Author:

Defined Under Namespace

Classes: Format, Reader, Writer

Class Method Summary collapse

Class Method Details

.escape(string) ⇒ String

Parameters:

Returns:

See Also:

Since:

  • 0.2.2



84
85
86
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-237066655558/lib/rdf/ntriples.rb', line 84

def self.escape(string)
  Writer.escape(string)
end

.serialize(value) ⇒ String

Returns the serialized N-Triples representation of the given RDF value.

Parameters:

Returns:

See Also:

Since:

  • 0.1.5



66
67
68
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-237066655558/lib/rdf/ntriples.rb', line 66

def self.serialize(value)
  Writer.for(:ntriples).serialize(value)
end

.unescape(string) ⇒ String

Parameters:

Returns:

See Also:

Since:

  • 0.2.2



75
76
77
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-237066655558/lib/rdf/ntriples.rb', line 75

def self.unescape(string)
  Reader.unescape(string)
end

.unserialize(data) ⇒ RDF::Value

Reconstructs an RDF value from its serialized N-Triples representation.

Parameters:

Returns:

See Also:

Since:

  • 0.1.5



54
55
56
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-237066655558/lib/rdf/ntriples.rb', line 54

def self.unserialize(data)
  Reader.unserialize(data)
end