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

ruby-changes:34698

From: hsbt <ko1@a...>
Date: Fri, 11 Jul 2014 15:41:58 +0900 (JST)
Subject: [ruby-changes:34698] hsbt:r46781 (trunk): * io.c: Improve Documentation by @dapplebeforedawn.

hsbt	2014-07-11 15:41:44 +0900 (Fri, 11 Jul 2014)

  New Revision: 46781

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

  Log:
    * io.c: Improve Documentation by @dapplebeforedawn.
      [fix GH-658] [ruby-core:63579] [Bug #10012]

  Modified files:
    trunk/ChangeLog
    trunk/io.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46780)
+++ ChangeLog	(revision 46781)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jul 11 15:39:36 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
+
+	* io.c: Improve Documentation by @dapplebeforedawn.
+	  [fix GH-658] [ruby-core:63579] [Bug #10012]
+
 Fri Jul 11 14:19:14 2014  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* lib/matrix.rb: Fix sign for cross_product [#9499]
Index: io.c
===================================================================
--- io.c	(revision 46780)
+++ io.c	(revision 46781)
@@ -9730,38 +9730,41 @@ seek_before_access(VALUE argp) https://github.com/ruby/ruby/blob/trunk/io.c#L9730
 
 /*
  *  call-seq:
- *     IO.read(name, [length [, offset]] )   -> string
- *     IO.read(name, [length [, offset]], open_args)   -> string
+ *     IO.read(name, [length [, offset]] [, opt] )   -> string
  *
  *  Opens the file, optionally seeks to the given +offset+, then returns
  *  +length+ bytes (defaulting to the rest of the file).  <code>read</code>
  *  ensures the file is closed before returning.
  *
- *  If the last argument is a hash, it specifies option for internal
- *  open().  The key would be the following.  open_args: is exclusive
- *  to others.
+ *  === Options
+ *
+ *  The options hash accepts the following keys:
  *
  *  encoding::
  *    string or encoding
  *
- *    specifies encoding of the read string.  +encoding+ will be ignored
- *    if length is specified.
+ *    Specifies the encoding of the read string.  +encoding:+ will be ignored
+ *    if +length+ is specified.  See Encoding.aliases for possible encodings.
  *
  *  mode::
  *    string
  *
- *    specifies mode argument for open().  It should start with "r"
- *    otherwise it will cause an error.
+ *    Specifies the mode argument for open().  It must start with an "r"
+ *    otherwise it will cause an error. See IO.new for the list of possible
+ *    modes.
  *
- *  open_args:: array of strings
+ *  open_args::
+ *    array of strings
  *
- *    specifies arguments for open() as an array.
+ *    Specifies arguments for open() as an array.  This key can not be used
+ *    in combination with either +encoding:+ or +mode:+.
  *
  *  Examples:
  *
- *    IO.read("testfile")           #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
- *    IO.read("testfile", 20)       #=> "This is line one\nThi"
- *    IO.read("testfile", 20, 10)   #=> "ne one\nThis is line "
+ *    IO.read("testfile")              #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
+ *    IO.read("testfile", 20)          #=> "This is line one\nThi"
+ *    IO.read("testfile", 20, 10)      #=> "ne one\nThis is line "
+ *    IO.read("binfile", mode: "rb")   #=> "\xF7\x00\x00\x0E\x12"
  */
 
 static VALUE

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

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