Class: BELRDF::GraphTranslator

Inherits:
Object
  • Object
show all
Includes:
BEL::Translator
Defined in:
lib/bel/translator/plugins/rdf/graph_translator.rb

Instance Method Summary collapse

Constructor Details

#initialize(format, write_schema = true) ⇒ GraphTranslator

Returns a new instance of GraphTranslator.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bel/translator/plugins/rdf/graph_translator.rb', line 14

def initialize(format, write_schema = true)
  @format     = format

  write_schema = true if write_schema.nil?
  @rdf_schema =
    if write_schema
      BELRDF::RDFS_SCHEMA
    else
      []
    end
end

Instance Method Details

#read(data, options = {}) ⇒ Object



26
27
28
# File 'lib/bel/translator/plugins/rdf/graph_translator.rb', line 26

def read(data, options = {})
  Reader::BufferedNanopubYielder.new(data, @format)
end

#write(objects, io = StringIO.new, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/bel/translator/plugins/rdf/graph_translator.rb', line 30

def write(objects, io = StringIO.new, options = {})
  write_rdf_to_io(@format, objects, io, options)

  case io
  when StringIO
    io.string
  else
    io
  end
end