[前][次][番号順一覧][スレッド一覧]

ruby-changes:14972

From: marcandre <ko1@a...>
Date: Sun, 7 Mar 2010 19:22:23 +0900 (JST)
Subject: [ruby-changes:14972] Ruby:r26844 (trunk): * io.c: Fix documentation for each/each_line/lines, bytes/each_byte,

marcandre	2010-03-07 19:22:05 +0900 (Sun, 07 Mar 2010)

  New Revision: 26844

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26844

  Log:
    * io.c: Fix documentation for each/each_line/lines, bytes/each_byte,
      codepoints/each_code_point [ruby-core:23948]
    
    * string.c: ditto
    
    * ext/stringio/stringio.c: ditto

  Modified files:
    trunk/ChangeLog
    trunk/ext/stringio/stringio.c
    trunk/io.c
    trunk/string.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26843)
+++ ChangeLog	(revision 26844)
@@ -1,3 +1,12 @@
+Sun Mar  7 19:21:10 2010  Marc-Andre Lafortune  <ruby-core@m...>
+
+	* io.c: Fix documentation for each/each_line/lines, bytes/each_byte,
+	  codepoints/each_code_point [ruby-core:23948]
+
+	* string.c: ditto
+
+	* ext/stringio/stringio.c: ditto
+
 Sun Mar  7 13:49:49 2010  Tanaka Akira  <akr@f...>
 
 	* file.c: add optional basedir argument for realpath/realdirpath.
Index: string.c
===================================================================
--- string.c	(revision 26843)
+++ string.c	(revision 26844)
@@ -5651,28 +5651,20 @@
 
 
 /*
- *  Document-method: lines
  *  call-seq:
- *     str.lines(separator=$/)   => anEnumerator
- *     str.lines(separator=$/) {|substr| block }        => str
- *
- *  Returns an enumerator that gives each line in the string.  If a block is
- *  given, it iterates over each line in the string.
- *
- *     "foo\nbar\n".lines.to_a   #=> ["foo\n", "bar\n"]
- *     "foo\nb ar".lines.sort    #=> ["b ar", "foo\n"]
- */
-
-/*
- *  Document-method: each_line
- *  call-seq:
  *     str.each_line(separator=$/) {|substr| block }   => str
+ *     str.each_line(separator=$/)                     => anEnumerator
  *
+ *     str.lines(separator=$/) {|substr| block }       => str
+ *     str.lines(separator=$/)                         => anEnumerator
+ *
  *  Splits <i>str</i> using the supplied parameter as the record separator
  *  (<code>$/</code> by default), passing each substring in turn to the supplied
  *  block. If a zero-length record separator is supplied, the string is split
  *  into paragraphs delimited by multiple successive newlines.
  *
+ *  If no block is given, an enumerator is returned instead.
+ *
  *     print "Example one\n"
  *     "hello\nworld".each_line {|s| p s}
  *     print "Example two\n"
@@ -5794,23 +5786,15 @@
 
 
 /*
- *  Document-method: bytes
  *  call-seq:
- *     str.bytes   => anEnumerator
- *     str.bytes {|fixnum| block }    => str
+ *     str.bytes {|fixnum| block }        => str
+ *     str.bytes                          => anEnumerator
  *
- *  Returns an enumerator that gives each byte in the string.  If a block is
- *  given, it iterates over each byte in the string.
- *
- *     "hello".bytes.to_a        #=> [104, 101, 108, 108, 111]
- */
-
-/*
- *  Document-method: each_byte
- *  call-seq:
  *     str.each_byte {|fixnum| block }    => str
+ *     str.each_byte                      => anEnumerator
  *
- *  Passes each byte in <i>str</i> to the given block.
+ *  Passes each byte in <i>str</i> to the given block, or returns
+ *  an enumerator if no block is given.
  *
  *     "hello".each_byte {|c| print c, ' ' }
  *
@@ -5833,23 +5817,15 @@
 
 
 /*
- *  Document-method: chars
  *  call-seq:
- *     str.chars                   => anEnumerator
- *     str.chars {|substr| block } => str
+ *     str.chars {|cstr| block }        => str
+ *     str.chars                        => anEnumerator
  *
- *  Returns an enumerator that gives each character in the string.
- *  If a block is given, it iterates over each character in the string.
- *
- *     "foo".chars.to_a   #=> ["f","o","o"]
- */
-
-/*
- *  Document-method: each_char
- *  call-seq:
  *     str.each_char {|cstr| block }    => str
+ *     str.each_char                    => anEnumerator
  *
- *  Passes each character in <i>str</i> to the given block.
+ *  Passes each character in <i>str</i> to the given block, or returns
+ *  an enumerator if no block is given.
  *
  *     "hello".each_char {|c| print c, ' ' }
  *
@@ -5889,28 +5865,19 @@
 }
 
 /*
- *  Document-method: codepoints
  *  call-seq:
- *     str.codepoints                   => anEnumerator
- *     str.codepoints {|fixnum| block } => str
+ *     str.codepoints {|integer| block }        => str
+ *     str.codepoints                           => anEnumerator
  *
- *  Returns an enumerator that gives the <code>Integer</code> ordinal
- *  of each character in the string, also known as a <i>codepoint</i>
- *  when applied to Unicode strings. If a block is given, it iterates
- *  over each character in the string.
- *
- *     "foo\u0635".codepoints.to_a   #=> [102, 111, 111, 1589]
- */
-
-/*
- *  Document-method: each_codepoint
- *  call-seq:
  *     str.each_codepoint {|integer| block }    => str
+ *     str.each_codepoint                       => anEnumerator
  *
  *  Passes the <code>Integer</code> ordinal of each character in <i>str</i>,
  *  also known as a <i>codepoint</i> when applied to Unicode strings to the
  *  given block.
  *
+ *  If no block is given, an enumerator is returned instead.
+ *
  *     "hello\u0639".each_codepoint {|c| print c, ' ' }
  *
  *  <em>produces:</em>
Index: io.c
===================================================================
--- io.c	(revision 26843)
+++ io.c	(revision 26844)
@@ -2613,33 +2613,27 @@
 
 /*
  *  call-seq:
- *     ios.lines(sep=$/)     => anEnumerator
- *     ios.lines(limit)      => anEnumerator
- *     ios.lines(sep, limit) => anEnumerator
- *
- *  Returns an enumerator that gives each line in <em>ios</em>.
- *  The stream must be opened for reading or an <code>IOError</code>
- *  will be raised.
- *
- *     f = File.new("testfile")
- *     f.lines.to_a  #=> ["foo\n", "bar\n"]
- *     f.rewind
- *     f.lines.sort  #=> ["bar\n", "foo\n"]
- */
-
-/*
- *  call-seq:
  *     ios.each(sep=$/) {|line| block }         => ios
  *     ios.each(limit) {|line| block }          => ios
  *     ios.each(sep,limit) {|line| block }      => ios
+ *     ios.each(...)                            => anEnumerator
+ *
  *     ios.each_line(sep=$/) {|line| block }    => ios
  *     ios.each_line(limit) {|line| block }     => ios
  *     ios.each_line(sep,limit) {|line| block } => ios
+ *     ios.each_line(...)                       => anEnumerator
  *
+ *     ios.lines(sep=$/) {|line| block }        => ios
+ *     ios.lines(limit) {|line| block }         => ios
+ *     ios.lines(sep,limit) {|line| block }     => ios
+ *     ios.lines(...)                           => anEnumerator
+ *
  *  Executes the block for every line in <em>ios</em>, where lines are
  *  separated by <i>sep</i>. <em>ios</em> must be opened for
  *  reading or an <code>IOError</code> will be raised.
  *
+ *  If no block is given, an enumerator is returned instead.
+ *
  *     f = File.new("testfile")
  *     f.each {|line| puts "#{f.lineno}: #{line}" }
  *
@@ -2667,26 +2661,18 @@
 
 /*
  *  call-seq:
- *     ios.bytes   => anEnumerator
+ *     ios.bytes {|byte| block }      => ios
+ *     ios.bytes                      => anEnumerator
  *
- *  Returns an enumerator that gives each byte (0..255) in <em>ios</em>.
- *  The stream must be opened for reading or an <code>IOError</code>
- *  will be raised.
- *
- *     f = File.new("testfile")
- *     f.bytes.to_a  #=> [104, 101, 108, 108, 111]
- *     f.rewind
- *     f.bytes.sort  #=> [101, 104, 108, 108, 111]
- */
-
-/*
- *  call-seq:
  *     ios.each_byte {|byte| block }  => ios
+ *     ios.each_byte                  => anEnumerator
  *
  *  Calls the given block once for each byte (0..255) in <em>ios</em>,
  *  passing the byte as an argument. The stream must be opened for
  *  reading or an <code>IOError</code> will be raised.
  *
+ *  If no block is given, an enumerator is returned instead.
+ *
  *     f = File.new("testfile")
  *     checksum = 0
  *     f.each_byte {|x| checksum ^= x }   #=> #<File:testfile>
@@ -2813,26 +2799,18 @@
 
 /*
  *  call-seq:
- *     ios.chars   => anEnumerator
+ *     ios.chars {|c| block }      => ios
+ *     ios.chars                   => anEnumerator
  *
- *  Returns an enumerator that gives each character in <em>ios</em>.
- *  The stream must be opened for reading or an <code>IOError</code>
- *  will be raised.
- *
- *     f = File.new("testfile")
- *     f.chars.to_a  #=> ["h", "e", "l", "l", "o"]
- *     f.rewind
- *     f.chars.sort  #=> ["e", "h", "l", "l", "o"]
- */
-
-/*
- *  call-seq:
  *     ios.each_char {|c| block }  => ios
+ *     ios.each_char               => anEnumerator
  *
  *  Calls the given block once for each character in <em>ios</em>,
  *  passing the character as an argument. The stream must be opened for
  *  reading or an <code>IOError</code> will be raised.
  *
+ *  If no block is given, an enumerator is returned instead.
+ *
  *     f = File.new("testfile")
  *     f.each_char {|c| print c, ' ' }   #=> #<File:testfile>
  */
@@ -9116,24 +9094,23 @@
 
 /*
  *  call-seq:
- *     ARGF.lines(sep=$/)                      => Enumerator
- *     ARGF.lines(sep=$/)          {|line| }   => Enumerator
- *     ARGF.lines(sep=$/,limit)                => Enumerator
- *     ARGF.lines(sep=$/,limit)    {|line| }   => Enumerator
+ *     ARGF.each(sep=$/)            {|line| block }  => ARGF
+ *     ARGF.each(sep=$/,limit)      {|line| block }  => ARGF
+ *     ARGF.each(...)                                => anEnumerator
  *
- *     ARGF.each_line(sep=$/)                  => Enumerator
- *     ARGF.each_line(sep=$/)       {|line| }  => Enumerator
- *     ARGF.each_line(sep=$/,limit)            => Enumerator
- *     ARGF.each_line(sep=$/,limit) {|line| }  => Enumerator
- *     ARGF.each(sep=$/)                       => Enumerator
- *     ARGF.each(sep=$/)            {|line| }  => Enumerator
- *     ARGF.each(sep=$/,limit)                 => Enumerator
- *     ARGF.each(sep=$/,limit)      {|line| }  => Enumerator
+ *     ARGF.each_line(sep=$/)       {|line| block }  => ARGF
+ *     ARGF.each_line(sep=$/,limit) {|line| block }  => ARGF
+ *     ARGF.each_line(...)                           => anEnumerator
  *
+ *     ARGF.lines(sep=$/)           {|line| block }   => ARGF
+ *     ARGF.lines(sep=$/,limit)     {|line| block }   => ARGF
+ *     ARGF.lines(...)                                => anEnumerator
+ *
  *  Returns an enumerator which iterates over each line (separated by _sep_,
  *  which defaults to your platform's newline character) of each file in
  *  +ARGV+. If a block is supplied, each line in turn will be yielded to the
- *  block. The optional _limit_ argument is a +Fixnum+ specifying the maximum
+ *  block, otherwise an enumerator is returned.
+ *  The optional _limit_ argument is a +Fixnum+ specifying the maximum
  *  length of each line; longer lines will be split according to this limit.
  *
  *  This method allows you to treat the files supplied on the command line as
@@ -9164,15 +9141,14 @@
 
 /*
  *  call-seq:
- *     ARGF.bytes                => Enumerator
- *     ARGF.bytes     {|byte| }  => Enumerator
+ *     ARGF.bytes     {|byte| block }  => ARGF
+ *     ARGF.bytes                      => anEnumerator
  *
- *     ARGF.each_byte            => Enumerator
- *     ARGF.each_byte {|byte| }  => Enumerator
+ *     ARGF.each_byte {|byte| block }  => ARGF
+ *     ARGF.each_byte                  => anEnumerator
  *
- *  Returns an enumerator which iterates over each byte of each file in
- *  +ARGV+. If a block is supplied, each byte in turn will be yielded to the
- *  block. A byte is returned as a +Fixnum+ in the range 0..255.
+ *  Iterates over each byte of each file in +ARGV+.
+ *  A byte is returned as a +Fixnum+ in the range 0..255.
  *
  *  This method allows you to treat the files supplied on the command line as
  *  a single file consisting of the concatenation of each named file. After
@@ -9180,6 +9156,8 @@
  *  second file is returned. The +ARGF.filename+ method can be used to
  *  determine the filename of the current byte.
  *
+ *  If no block is given, an enumerator is returned instead.
+ *
  * For example:
  *
  *     ARGF.bytes.to_a  #=> [35, 32, ... 95, 10]
@@ -9198,15 +9176,13 @@
 
 /*
  *  call-seq:
- *     ARGF.chars                 => Enumerator
- *     ARGF.chars      {|char| }  => Enumerator
+ *     ARGF.chars      {|char| block }  => ARGF
+ *     ARGF.chars                       => anEnumerator
  *
- *     ARGF.each_char             => Enumerator
- *     ARGF.each_char  {|char| }  => Enumerator
+ *     ARGF.each_char  {|char| block }  => ARGF
+ *     ARGF.each_char                   => anEnumerator
  *
- *  Returns an enumerator which iterates over each character of each file in
- *  +ARGV+. If a block is supplied, each character in turn will be yielded to
- *  the block.
+ *  Iterates over each character of each file in +ARGF+.
  *
  *  This method allows you to treat the files supplied on the command line as
  *  a single file consisting of the concatenation of each named file. After
@@ -9214,6 +9190,8 @@
  *  character of the second file is returned. The +ARGF.filename+ method can
  *  be used to determine the name of the file in which the current character
  *  appears.
+ *
+ *  If no block is given, an enumerator is returned instead.
  */
 static VALUE
 argf_each_char(VALUE argf)
Index: ext/stringio/stringio.c
===================================================================
--- ext/stringio/stringio.c	(revision 26843)
+++ ext/stringio/stringio.c	(revision 26844)
@@ -615,7 +615,11 @@
 
 /*
  * call-seq:
+ *   strio.bytes {|byte| block }      -> strio
+ *   strio.bytes                      -> anEnumerator
+ *
  *   strio.each_byte {|byte| block }  -> strio
+ *   strio.each_byte                  -> anEnumerator
  *
  * See IO#each_byte.
  */
@@ -821,7 +825,11 @@
 
 /*
  * call-seq:
+ *   strio.chars {|char| block }      -> strio
+ *   strio.chars                      -> anEnumerator
+ *
  *   strio.each_char {|char| block }  -> strio
+ *   strio.each_char                  -> anEnumerator
  *
  * See IO#each_char.
  */
@@ -840,7 +848,11 @@
 
 /*
  * call-seq:
+ *   strio.codepoints {|c| block }      -> strio
+ *   strio.codepoints                   -> anEnumerator
+ *
  *   strio.each_codepoint {|c| block }  -> strio
+ *   strio.each_codepoint               -> anEnumerator
  *
  * See IO#each_codepoint.
  */
@@ -1031,10 +1043,18 @@
  *   strio.each(sep=$/) {|line| block }         -> strio
  *   strio.each(limit) {|line| block }          -> strio
  *   strio.each(sep, limit) {|line| block }     -> strio
+ *   strio.each(...)                            -> anEnumerator
+ *
  *   strio.each_line(sep=$/) {|line| block }    -> strio
  *   strio.each_line(limit) {|line| block }     -> strio
  *   strio.each_line(sep,limit) {|line| block } -> strio
+ *   strio.each_line(...)                       -> anEnumerator
  *
+ *   strio.lines(sep=$/) {|line| block }        -> strio
+ *   strio.lines(limit) {|line| block }         -> strio
+ *   strio.lines(sep,limit) {|line| block }     -> strio
+ *   strio.lines(...)                           -> anEnumerator
+ *
  * See IO#each.
  */
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]