Class: BELRDF::Reader::UnbufferedNanopubYielder
- Inherits:
-
Object
- Object
- BELRDF::Reader::UnbufferedNanopubYielder
- Includes:
- NanopubYielder
- Defined in:
- lib/bel/translator/plugins/rdf/reader.rb
Constant Summary
Constants included from NanopubYielder
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
- #each ⇒ Object
-
#initialize(data, format) ⇒ UnbufferedNanopubYielder
constructor
A new instance of UnbufferedNanopubYielder.
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) ⇒ UnbufferedNanopubYielder
Returns a new instance of UnbufferedNanopubYielder.
124 125 126 127 |
# File 'lib/bel/translator/plugins/rdf/reader.rb', line 124 def initialize(data, format) @data = data @format = format end |
Instance Method Details
#each ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/bel/translator/plugins/rdf/reader.rb', line 129 def each if block_given? graph = RDF::Graph.new nanopub = nil RDF::Reader.for(@format).new(@data) do |reader| reader.each_statement do |statement| case when statement.object == BELV.Nanopub && statement.predicate == RDF.type nanopub = statement.subject when nanopub && statement.predicate != BELV.hasNanopub && statement.subject != nanopub # yield current graph as nanopub yield make_nanopub( describe(nanopub, graph), graph ) # reset parse state graph.clear nanopub = nil # insert this RDF statement graph << statement else graph << statement end end end # yield last graph as nanopub yield make_nanopub( describe(nanopub, graph), graph ) else to_enum(:each) end end |