class RDF::Format

The base class for RDF serialization formats.

@example Loading an RDF serialization format implementation

require 'rdf/ntriples'

@example Iterating over known RDF serialization formats

RDF::Format.each { |klass| puts klass.name }

@example Getting a serialization format class

RDF::Format.for(:ntriples)     #=> RDF::NTriples::Format
RDF::Format.for("etc/doap.nt")
RDF::Format.for(file_name: "etc/doap.nt")
RDF::Format.for(file_extension: "nt")
RDF::Format.for(content_type: "application/n-triples")

@example Obtaining serialization format MIME types

RDF::Format.content_types      #=> {"application/n-triples" => [RDF::NTriples::Format]}

@example Obtaining serialization format file extension mappings

RDF::Format.file_extensions    #=> {nt: [RDF::NTriples::Format]}

@example Defining a new RDF serialization format class

class RDF::NTriples::Format < RDF::Format
  content_type     'application/n-triples',
                   extension: :nt,
                   uri: RDF::URI("http://www.w3.org/ns/formats/N-Triples")
  content_encoding 'utf-8'

  reader RDF::NTriples::Reader
  writer RDF::NTriples::Writer
end

@example Instantiating an RDF reader or writer class (1)

RDF::Format.for(:ntriples).reader.new($stdin)  { |reader| ... }
RDF::Format.for(:ntriples).writer.new($stdout) { |writer| ... }

@example Instantiating an RDF reader or writer class (2)

RDF::Reader.for(:ntriples).new($stdin)  { |reader| ... }
RDF::Writer.for(:ntriples).new($stdout) { |writer| ... }

@abstract @see RDF::Reader @see RDF::Writer @see en.wikipedia.org/wiki/Resource_Description_Framework#Serialization_formats