Class: Bio::BlastXMLParser::NokogiriBlastXml

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/db/blast/parser/nokogiri.rb

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ NokogiriBlastXml

Returns a new instance of NokogiriBlastXml.



180
181
182
# File 'lib/bio/db/blast/parser/nokogiri.rb', line 180

def initialize document
  @xml = document
end

Instance Method Details

#each(&block) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/bio/db/blast/parser/nokogiri.rb', line 190

def each &block
  doc = Nokogiri::XML(@xml) { | cfg | cfg.noblanks }
  doc.root.children.each do |blastnode|
    if blastnode.name == 'BlastOutput_iterations'
      blastnode.children.each do | iteration |
        if iteration.name == 'Iteration'
          block.call(NokogiriBlastIterator.new(iteration,self))
        end
      end
    end
  end
end

#to_enumObject



184
185
186
187
188
# File 'lib/bio/db/blast/parser/nokogiri.rb', line 184

def to_enum
  Enumerator.new { |yielder| 
    each { | iterator | yielder.yield(iterator) }
  }
end