[macruby-changes] [2247] MacRuby/trunk/lib/stringio.rb

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 6 14:51:18 PDT 2009


Revision: 2247
          http://trac.macosforge.org/projects/ruby/changeset/2247
Author:   mattaimonetti at gmail.com
Date:     2009-08-06 14:51:18 -0700 (Thu, 06 Aug 2009)
Log Message:
-----------
added readline to StringIO

Modified Paths:
--------------
    MacRuby/trunk/lib/stringio.rb

Modified: MacRuby/trunk/lib/stringio.rb
===================================================================
--- MacRuby/trunk/lib/stringio.rb	2009-08-06 20:27:46 UTC (rev 2246)
+++ MacRuby/trunk/lib/stringio.rb	2009-08-06 21:51:18 UTC (rev 2247)
@@ -285,7 +285,7 @@
   # See IO#readchar.
   #
   def readchar
-    raise(IO::EOFError, "end of file reached") if self.eof?
+    raise(IO::EOFError, "end of file reached") if eof?
     getc
   end
   
@@ -324,7 +324,17 @@
   # See IO#gets.
   #
   def gets(sep=$/)
-    $_ = self.getline(sep)
+    $_ = getline(sep)
+  end
+  
+  #   strio.readline(sep=$/)     -> string
+  #   strio.readline(limit)      -> string or nil
+  #   strio.readline(sep, limit) -> string or nil
+  #
+  # See IO#readline.
+  def readline(sep=$/)
+    raise(IO::EOFError, 'end of file reached') if eof?
+    $_ = getline(sep)
   end 
            
 
@@ -399,7 +409,7 @@
     def getline(sep = $/)
       raise(IOError, "not opened for reading") unless @readable
       sep = sep.to_str unless (sep.nil? || sep.kind_of?(String))
-      return nil if self.eof?
+      return nil if eof?
 
       if sep.nil?
         line = string[pos .. -1]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090806/3a940840/attachment.html>


More information about the macruby-changes mailing list