diff options
author | stomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-05 19:43:10 +0000 |
---|---|---|
committer | stomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-05 19:43:10 +0000 |
commit | 5dfde64609f4595c599ed8d99e5fdb82240ecf73 (patch) | |
tree | e19756250b399e30fd3aa851701bb6bb81dc44a8 /io.c | |
parent | 6af78021d42000045f4897c1a6d624b6b714f4f4 (diff) | |
download | ruby-5dfde64609f4595c599ed8d99e5fdb82240ecf73.tar.gz |
docs for IO.{write,read}
* io.c: [DOC] improve docs for IO
* IO.{write,read}: fix errors (:open_args is not an array of
strings, it might include a perm or options hash argument;
IO.write has no length argument, drop corresponding statement),
improve formatting, call-seq, grammar.
* IO#sync=: remove unnecessary "produces no output".
* other improvements.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 67 |
1 files changed, 35 insertions, 32 deletions
@@ -1881,8 +1881,6 @@ rb_io_sync(VALUE io) * * f = File.new("testfile") * f.sync = true - * - * <em>(produces no output)</em> */ static VALUE @@ -9928,24 +9926,24 @@ seek_before_access(VALUE argp) * * The options hash accepts the following keys: * - * encoding:: + * :encoding:: * string or encoding * - * Specifies the encoding of the read string. +encoding:+ will be ignored + * Specifies the encoding of the read string. +:encoding+ will be ignored * if +length+ is specified. See Encoding.aliases for possible encodings. * - * mode:: + * :mode:: * string * - * 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. + * Specifies the <i>mode</i> 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 * * Specifies arguments for open() as an array. This key can not be used - * in combination with either +encoding:+ or +mode:+. + * in combination with either +:encoding+ or +:mode+. * * Examples: * @@ -10086,8 +10084,8 @@ io_s_write(int argc, VALUE *argv, int binary) /* * call-seq: - * IO.write(name, string, [offset] ) => integer - * IO.write(name, string, [offset], open_args ) => integer + * IO.write(name, string [, offset]) -> integer + * IO.write(name, string [, offset] [, opt]) -> integer * * Opens the file, optionally seeks to the given <i>offset</i>, writes * <i>string</i>, then returns the length written. @@ -10095,32 +10093,37 @@ io_s_write(int argc, VALUE *argv, int binary) * If <i>offset</i> is not given, the file is truncated. Otherwise, * it is not truncated. * - * 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. + * IO.write("testfile", "0123456789", 20) #=> 10 + * # File could contain: "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n" + * IO.write("testfile", "0123456789") #=> 10 + * # File would now read: "0123456789" * - * encoding: string or encoding + * If the last argument is a hash, it specifies options for the internal + * open(). It accepts the following keys: * - * specifies encoding of the read string. encoding will be ignored - * if length is specified. + * :encoding:: + * string or encoding * - * mode: string + * Specifies the encoding of the read string. + * See Encoding.aliases for possible encodings. * - * specifies mode argument for open(). it should start with "w" or "a" or "r+" - * otherwise it would cause error. + * :mode:: + * string * - * perm: integer + * Specifies the <i>mode</i> argument for open(). It must start + * with "w", "a", or "r+", otherwise it will cause an error. + * See IO.new for the list of possible modes. * - * specifies perm argument for open(). + * :perm:: + * integer * - * open_args: array + * Specifies the <i>perm</i> argument for open(). * - * specifies arguments for open() as an array. + * :open_args:: + * array * - * IO.write("testfile", "0123456789", 20) # => 10 - * # File could contain: "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n" - * IO.write("testfile", "0123456789") #=> 10 - * # File would now read: "0123456789" + * Specifies arguments for open() as an array. + * This key can not be used in combination with other keys. */ static VALUE @@ -12265,13 +12268,13 @@ rb_readwrite_syserr_fail(enum rb_io_wait_readwrite writable, int n, const char * * <code>"\gumby\ruby\test.rb"</code>. When specifying a Windows-style * filename in a Ruby string, remember to escape the backslashes: * - * "c:\\gumby\\ruby\\test.rb" + * "C:\\gumby\\ruby\\test.rb" * * Our examples here will use the Unix-style forward slashes; * File::ALT_SEPARATOR can be used to get the platform-specific separator * character. * - * The global constant ARGF (also accessible as $<) provides an + * The global constant ARGF (also accessible as <code>$<</code>) provides an * IO-like stream which allows access to all files mentioned on the * command line (or STDIN if no files are mentioned). ARGF#path and its alias * ARGF#filename are provided to access the name of the file currently being |