[BioRuby-cvs] bioruby/lib/bio/io flatfile.rb,1.59,1.60

Naohisa Goto ngoto at dev.open-bio.org
Mon Jul 9 14:08:36 UTC 2007


Update of /home/repository/bioruby/bioruby/lib/bio/io
In directory dev.open-bio.org:/tmp/cvs-serv30708/lib/bio/io

Modified Files:
	flatfile.rb 
Log Message:
Bio::FlatFile.foreach is added (which is suggested by IO.foreach).


Index: flatfile.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** flatfile.rb	14 Apr 2007 02:29:45 -0000	1.59
--- flatfile.rb	9 Jul 2007 14:08:34 -0000	1.60
***************
*** 509,512 ****
--- 509,526 ----
      end
  
+     # Executes the block for every entry in the stream.
+     # Same as FlatFile.open(*arg) { |ff| ff.each { |entry| ... }}.
+     # 
+     # * Example
+     #     Bio::FlatFile.foreach('test.fst') { |e| puts e.definition }
+     #
+     def self.foreach(*arg)
+       self.open(*arg) do |flatfileobj|
+         flatfileobj.each do |entry|
+           yield entry
+         end
+       end
+     end
+ 
      # Same as FlatFile.open, except that 'stream' should be a opened
      # stream object (IO, File, ..., who have the 'gets' method).




More information about the bioruby-cvs mailing list