Class: BEL::Extension::Format::BELYielder
- Inherits:
-
Object
- Object
- BEL::Extension::Format::BELYielder
- Defined in:
- lib/bel/extensions/bel.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(data, options = {}) ⇒ BELYielder
constructor
A new instance of BELYielder.
Constructor Details
#initialize(data, options = {}) ⇒ BELYielder
Returns a new instance of BELYielder.
127 128 129 130 |
# File 'lib/bel/extensions/bel.rb', line 127 def initialize(data, = {}) @data = data @write_header = ([:write_header] || true) end |
Instance Method Details
#each ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/bel/extensions/bel.rb', line 132 def each if block_given? header_flag = true @data.each { |evidence| bel = to_bel(evidence) if @write_header && header_flag yield document_header(evidence..document_header) yield namespace_definitions( evidence.references.namespace_definitions ) yield annotation_definitions( evidence.references.annotation_definitions ) header_flag = false end yield bel } else to_enum(:each) end end |