Class: BioInterchange::TextMining::RDFWriter

Inherits:
Writer
  • Object
show all
Defined in:
lib/biointerchange/textmining/text_mining_rdf_ntriples.rb

Instance Method Summary collapse

Methods inherited from Writer

#add_prefix, #close, #create_triple, #set_base

Constructor Details

#initialize(ostream) ⇒ RDFWriter

Creates a new instance of a RDFWriter that will use the provided output stream to serialize RDF.

ostream

instance of an IO class or derivative that is used for RDF serialization



21
22
23
# File 'lib/biointerchange/textmining/text_mining_rdf_ntriples.rb', line 21

def initialize(ostream)
  super(ostream)
end

Instance Method Details

#serialize(model, uri_prefix = nil) ⇒ Object

Serializes a model as RDF.

model

a generic representation of input data that is derived from BioInterchange::TextMining::Document

uri_prefix

optional URI prefix that should be used in the RDFization of individuals/class instances



29
30
31
32
33
34
35
36
# File 'lib/biointerchange/textmining/text_mining_rdf_ntriples.rb', line 29

def serialize(model, uri_prefix = nil)
  if model.instance_of?(BioInterchange::TextMining::Document) then
    serialize_document(model, uri_prefix)
  else
    raise BioInterchange::Exceptions::ImplementationWriterError, 'The provided model cannot be serialized at the moment. ' +
                         'Supported classes are BioInterchange::TextMining::Document (and that\'s it for now).'
  end
end