Class: BEL::Translator::Plugins::Xbel::XbelTranslator

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

Instance Method Summary collapse

Instance Method Details

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



9
10
11
# File 'lib/bel/translator/plugins/xbel/translator.rb', line 9

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

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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bel/translator/plugins/xbel/translator.rb', line 13

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