Sha256: dbac4795bec7bbfcd3429fd27e60230cada68d2948e0dd0fdedefedd799d80d4

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'bel_parser'
require 'bel_parser/resource/resource_url_reader'
require 'bel/nanopub'

module BEL::Translator::Plugins
  module BelScript
    class Reader
      include ::BELParser::Script
      
      SyntaxError = ::BELParser::Language::Syntax::SyntaxError

      def initialize(io, options = {})
        @io    = io
        @state = {
          resource_reader: BELParser::Resource::ResourceURLReader.new(true),
          specification: BELParser::Language.specification('2.0'),
          namespace_definitions: {}
        }
      end

      def each
        if block_given?
          NanopubMapper.new(
            Validator.new(
              StateAggregator.new(
                FirstNode.new(Filter.new(BELParser::ASTGenerator.new(@io))),
                @state)),
            true,
            false
          ).each do |(num, line, ast_node, nanopub_hash)|
                  yield ::BEL::Nanopub::Nanopub.create(nanopub_hash)
                end
        else
          enum_for(:each)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bel_parser-1.0.0.alpha.23 lib/bel/translator/plugins/bel_script/reader.rb