lib/bel/translator/plugins/bel_script/translator.rb in bel_parser-1.0.0.alpha.20 vs lib/bel/translator/plugins/bel_script/translator.rb in bel_parser-1.0.0.alpha.21

- old
+ new

@@ -1,35 +1,37 @@ # Requires the "bel" gem. # This is for the BelScript translator intended to be plugged into bel.rb. require 'bel/translator' +require_relative 'reader' +require_relative 'writer' module BEL::Translator::Plugins module BelScript # BelScriptTranslator defines a {BEL::Translator} that can read/write # BEL Script using the Nanopub model. class BelScriptTranslator include ::BEL::Translator def read(data, options = {}) - # EvidenceYielder.new(data, options) + Reader.new(data) end def write(objects, writer = StringIO.new, options = {}) - # if block_given? - # BelYielder.new(objects, options).each { |bel_part| - # yield bel_part - # } - # else - # if writer - # BelYielder.new(objects, options).each { |bel_part| - # writer << "#{bel_part}" - # writer.flush - # } - # writer - # else - # BelYielder.new(objects, options) - # end - # end + 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 end end end