[macruby-changes] [2240] MacRuby/trunk/lib/stringio.rb
source_changes at macosforge.org
source_changes at macosforge.org
Thu Aug 6 01:41:24 PDT 2009
Revision: 2240
http://trac.macosforge.org/projects/ruby/changeset/2240
Author: mattaimonetti at gmail.com
Date: 2009-08-06 01:41:23 -0700 (Thu, 06 Aug 2009)
Log Message:
-----------
added each_char and chars
Modified Paths:
--------------
MacRuby/trunk/lib/stringio.rb
Modified: MacRuby/trunk/lib/stringio.rb
===================================================================
--- MacRuby/trunk/lib/stringio.rb 2009-08-06 07:44:21 UTC (rev 2239)
+++ MacRuby/trunk/lib/stringio.rb 2009-08-06 08:41:23 UTC (rev 2240)
@@ -285,9 +285,25 @@
# See IO#readchar.
#
def readchar
-
+ raise(IO::EOFError, "end of file reached") if self.eof?
+ getc
end
+ # strio.each_char {|char| block } -> strio
+ #
+ # See IO#each_char.
+ #
+ def each_char
+ raise(IOError, "not opened for reading") unless @readable
+ if block_given?
+ string.each_char{|c| yield(c)}
+ self
+ else
+ string.each_char
+ end
+ end
+ alias_method :chars, :each_char
+
# strio.getbyte -> fixnum or nil
#
# See IO#getbyte.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090806/a11da9eb/attachment.html>
More information about the macruby-changes
mailing list