class BEL::Translator::Plugins::BelScript::Reader

Constants

SyntaxError

Public Class Methods

new(io, options = {}) click to toggle source
# File lib/bel/translator/plugins/bel_script/reader.rb, line 12
def initialize(io, options = {})
  @io    = io

  options = {
    :language => '1.0'
  }.merge(options)

  @state = {
    uri_reader:            BELParser::Resource.default_uri_reader,
    url_reader:            BELParser::Resource.default_url_reader,
    specification:         BELParser::Language.specification(options[:language]),
    namespace_definitions: {}
  }.merge(options)
end

Public Instance Methods

each() { |create| ... } click to toggle source
# File lib/bel/translator/plugins/bel_script/reader.rb, line 27
def each
  if block_given?
    NanopubMapper.new(
      Validator.new(
        StateAggregator.new(
          FirstNode.new(Filter.new(BELParser::ASTGenerator.new(@io))),
          @state))
    ).each do |(num, line, ast_node, nanopub_hash)|
      yield ::BEL::Nanopub::Nanopub.create(nanopub_hash)
    end
  else
    enum_for(:each)
  end
end