summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-11 06:41:44 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-11 06:41:44 +0000
commitdcf296f74c6dd8f2d3fddab00f3b0f621d74ef40 (patch)
tree80770e49642028bf75b8d9407649cfa8de153dd8 /io.c
parent72d05366066176f73d7199da67036c4f8778595a (diff)
* io.c: Improve Documentation by @dapplebeforedawn.
[fix GH-658] [ruby-core:63579] [Bug #10012] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/io.c b/io.c
index 731b3054f6..56089e4de5 100644
--- a/io.c
+++ b/io.c
@@ -9730,38 +9730,41 @@ seek_before_access(VALUE argp)
/*
* 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