[BioRuby-cvs] bioruby/lib/bio/shell session.rb,1.8,1.9

Katayama Toshiaki k at pub.open-bio.org
Mon Nov 28 02:11:02 EST 2005


Update of /home/repository/bioruby/bioruby/lib/bio/shell
In directory pub.open-bio.org:/tmp/cvs-serv9725/bio/shell

Modified Files:
	session.rb 
Log Message:
* save method is renamed to savefile
* head method also accepts object (not only the filename)


Index: session.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/shell/session.rb,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** session.rb	27 Nov 2005 17:39:00 -0000	1.8
--- session.rb	28 Nov 2005 07:10:59 -0000	1.9
***************
*** 104,108 ****
    end
  
!   def display(*obj)
      # The original idea is from http://sheepman.parfait.ne.jp/20050215.html
      if Bio::Shell.config[:pager]
--- 104,108 ----
    end
  
!   def display(*obj)             # *TODO* spec?
      # The original idea is from http://sheepman.parfait.ne.jp/20050215.html
      if Bio::Shell.config[:pager]
***************
*** 127,138 ****
    end
  
!   def head(file, num = 10)
      str = ""
!     File.open(file) do |f|
!       num.times do
!         if line = f.gets
!           str << line
          end
        end
      end
      display str
--- 127,145 ----
    end
  
!   def head(arg, num = 10)
      str = ""
!     if File.exists?(arg)
!       File.open(arg) do |file|
!         num.times do
!           if line = file.gets
!             str << line
!           end
          end
        end
+     else
+       arg.to_s.each_with_index do |line, i|
+         break if i >= num
+         str << line
+       end
      end
      display str
***************
*** 141,145 ****
    ### file save
  
!   def save(file, *objs)
      if File.exists?(file)
        loop do
--- 148,152 ----
    ### file save
  
!   def savefile(file, *objs)
      if File.exists?(file)
        loop do



More information about the bioruby-cvs mailing list