Module: BEL::Format

Defined in:
lib/bel/format.rb

Defined Under Namespace

Classes: EvidenceIterable

Constant Summary collapse

Format =
BEL::Extension::Format
FormatError =
BEL::Extension::Format::FormatError

Class Method Summary collapse

Class Method Details

.evidence(input, input_format) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/bel/format.rb', line 6

def self.evidence(input, input_format)
  prepared_input = process_input(input)

  in_formatter  = BEL::Extension::Format.formatters(input_format) or
    raise FormatError.new(input_format)

  EvidenceIterable.new(prepared_input, in_formatter)
end

.translate(input, input_format, output_format, writer = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bel/format.rb', line 15

def self.translate(input, input_format, output_format, writer = nil)
  prepared_input = process_input(input)

  in_formatter  = BEL::Extension::Format.formatters(input_format) or
    raise FormatError.new(input_format)

  out_formatter = BEL::Extension::Format.formatters(output_format) or
    raise FormatError.new(output_format)

  objects = in_formatter.deserialize(prepared_input)
  output = out_formatter.serialize(objects, writer)
end