[BioRuby-cvs] bioruby/lib/bio/io flatfile.rb,1.49,1.50
Naohisa Goto
ngoto at dev.open-bio.org
Mon Jun 12 10:35:44 UTC 2006
Update of /home/repository/bioruby/bioruby/lib/bio/io
In directory dev.open-bio.org:/tmp/cvs-serv15886/lib/bio/io
Modified Files:
flatfile.rb
Log Message:
Bio::FlatFile.open(klass, filename) didn't work.
Index: flatfile.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/io/flatfile.rb,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** flatfile.rb 22 Mar 2006 10:19:22 -0000 1.49
--- flatfile.rb 12 Jun 2006 10:35:42 -0000 1.50
***************
*** 426,430 ****
unless file.respond_to?(:gets)
# 'file' is a filename
! self.open_file(file, *arg, &block)
else
# 'file' is a IO object
--- 426,430 ----
unless file.respond_to?(:gets)
# 'file' is a filename
! _open_file(dbclass, file, *arg, &block)
else
# 'file' is a IO object
***************
*** 466,478 ****
#
def self.open_file(filename, *arg)
if block_given? then
BufferedInputStream.open_file(filename, *arg) do |stream|
! yield self.new(nil, stream)
end
else
stream = BufferedInputStream.open_file(filename, *arg)
! self.new(nil, stream)
end
end
# Opens URI specified as _uri_.
--- 466,490 ----
#
def self.open_file(filename, *arg)
+ _open_file(nil, filename, *arg)
+ end
+
+ # Same as FlatFile.open(dbclass, filename, *arg),
+ # except that it only accept filename and doesn't accept IO object.
+ #
+ # It can accept a block.
+ # If a block is given, it returns the block's return value.
+ # Otherwise, it returns a new FlatFile object.
+ #
+ def self._open_file(dbclass, filename, *arg)
if block_given? then
BufferedInputStream.open_file(filename, *arg) do |stream|
! yield self.new(dbclass, stream)
end
else
stream = BufferedInputStream.open_file(filename, *arg)
! self.new(dbclass, stream)
end
end
+ private_class_method :_open_file
# Opens URI specified as _uri_.
More information about the bioruby-cvs
mailing list