Class: BEL::BELRDF::Reader::BufferedNanopubYielder

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

Constant Summary

Constants included from Quoting

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

Instance Method Summary collapse

Methods included from NanopubYielder

#describe, #make_nanopub, #nanopub_yielder, #resources_of_type

Methods included from Quoting

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

Methods included from Nanopub

union_annotation_references, union_by_keyword, union_namespace_references

Constructor Details

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

Returns a new instance of BufferedNanopubYielder.



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

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

Instance Method Details

#eachObject



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

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