Class: BELRDF::Reader::BufferedNanopubYielder

Inherits:
Object
  • Object
show all
Includes:
NanopubYielder
Defined in:
lib/bel/translator/plugins/rdf/reader.rb

Constant Summary

Constants included from NanopubYielder

NanopubYielder::BELV

Constants included from BEL::Quoting

BEL::Quoting::KeywordMatcher, BEL::Quoting::Keywords, BEL::Quoting::LenientQuotedMatcher, BEL::Quoting::NonWordMatcher, BEL::Quoting::QuoteNotEscapedMatcher, BEL::Quoting::StrictQuotedMatcher

Instance Method Summary collapse

Methods included from NanopubYielder

#describe, #make_nanopub, #nanopub_yielder, #resources_of_type

Methods included from BEL::Quoting

#always_quote, #ensure_quotes, #identifier_value?, #quote, #quote_if_needed, #quoted?, #quotes_required?, #remove_quotes, #string_value?, #unquote, #unquoted?

Methods included from BEL::Nanopub

union_annotation_references, union_by_keyword, union_namespace_references

Constructor Details

#initialize(data, format = :ntriples) ⇒ BufferedNanopubYielder

Returns a new instance of BufferedNanopubYielder.



98
99
100
101
# File 'lib/bel/translator/plugins/rdf/reader.rb', line 98

def initialize(data, format = :ntriples)
  @data   = data
  @format = format
end

Instance Method Details

#eachObject



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/bel/translator/plugins/rdf/reader.rb', line 103

def each
  if block_given?
    graph = RDF::Graph.new
    RDF::Reader.for(@format).new(@data) do |reader|
      reader.each_statement do |statement|
        graph << statement
      end
    end
    nanopub_yielder(graph) do |nanopub|
      yield nanopub
    end
  else
    to_enum(:each)
  end
end