Class: BEL::Translator::Plugins::BelScript::BelScriptTranslator

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

Overview

BelScriptTranslator defines a BEL::Translator that can read/write BEL Script using the Nanopub model.

Instance Method Summary collapse

Instance Method Details

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



14
15
16
# File 'lib/bel/translator/plugins/bel_script/translator.rb', line 14

def read(data, options = {})
  Reader.new(data, options)
end

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



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bel/translator/plugins/bel_script/translator.rb', line 18

def write(objects, writer = StringIO.new, options = {})
  if block_given?
    Writer.new(objects, options).each { |bel_part|
      yield bel_part
    }
  else
    if writer
      Writer.new(objects, options).each { |bel_part|
        writer << "#{bel_part}"
        writer.flush
      }
      writer
    else
      Writer.new(objects, options)
    end
  end
end