1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[DOC] fix markups [ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2019-03-22 11:04:59 +00:00
parent c671f836b4
commit 56557ec28a
15 changed files with 447 additions and 479 deletions

10
ast.c
View file

@ -77,10 +77,10 @@ ast_parse_done(rb_ast_t *ast)
* call-seq:
* RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node
*
* Parses the given string into an abstract syntax tree,
* Parses the given _string_ into an abstract syntax tree,
* returning the root node of that tree.
*
* SyntaxError is raised if the given string is invalid syntax.
* SyntaxError is raised if the given _string_ is invalid syntax.
*
* RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
* # => #<RubyVM::AbstractSyntaxTree::Node(NODE_SCOPE(0) 1:0, 1:9): >
@ -105,10 +105,10 @@ rb_ast_parse_str(VALUE str)
* call-seq:
* RubyVM::AbstractSyntaxTree.parse_file(pathname) -> RubyVM::AbstractSyntaxTree::Node
*
* Reads the file from <code>pathname</code>, then parses it like ::parse,
* Reads the file from _pathname_, then parses it like ::parse,
* returning the root node of the abstract syntax tree.
*
* SyntaxError is raised if <code>pathname</code>'s contents are not
* SyntaxError is raised if _pathname_'s contents are not
* valid Ruby syntax.
*
* RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb")
@ -205,7 +205,7 @@ script_lines(VALUE path)
* RubyVM::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node
* RubyVM::AbstractSyntaxTree.of(method) -> RubyVM::AbstractSyntaxTree::Node
*
* Returns AST nodes of the given proc or method.
* Returns AST nodes of the given _proc_ or _method_.
*
* RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
* # => #<RubyVM::AbstractSyntaxTree::Node(NODE_SCOPE(0) 1:35, 1:42): >

View file

@ -5500,8 +5500,8 @@ rb_big_le(VALUE x, VALUE y)
* big == obj -> true or false
*
* Returns <code>true</code> only if <i>obj</i> has the same value
* as <i>big</i>. Contrast this with <code>Integer#eql?</code>, which
* requires <i>obj</i> to be a <code>Integer</code>.
* as <i>big</i>. Contrast this with Integer#eql?, which requires
* <i>obj</i> to be a Integer.
*
* 68719476736 == 68719476736.0 #=> true
*/

View file

@ -207,16 +207,16 @@ cmp_clamp(VALUE x, VALUE min, VALUE max)
}
/*
* The <code>Comparable</code> mixin is used by classes whose objects
* may be ordered. The class must define the <code><=></code> operator,
* which compares the receiver against another object, returning -1, 0,
* or +1 depending on whether the receiver is less than, equal to, or
* greater than the other object. If the other object is not comparable
* then the <code><=></code> operator should return nil.
* <code>Comparable</code> uses
* <code><=></code> to implement the conventional comparison operators
* (<code><</code>, <code><=</code>, <code>==</code>, <code>>=</code>,
* and <code>></code>) and the method <code>between?</code>.
* The Comparable mixin is used by classes whose objects may be
* ordered. The class must define the <code><=></code> operator,
* which compares the receiver against another object, returning -1,
* 0, or +1 depending on whether the receiver is less than, equal to,
* or greater than the other object. If the other object is not
* comparable then the <code><=></code> operator should return +nil+.
* Comparable uses <code><=></code> to implement the conventional
* comparison operators (<code><</code>, <code><=</code>,
* <code>==</code>, <code>>=</code>, and <code>></code>) and the
* method <code>between?</code>.
*
* class SizeMatters
* include Comparable

49
cont.c
View file

@ -1135,7 +1135,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
* Continuation objects are generated by Kernel#callcc,
* after having +require+d <i>continuation</i>. They hold
* a return address and execution context, allowing a nonlocal return
* to the end of the <code>callcc</code> block from anywhere within a
* to the end of the #callcc block from anywhere within a
* program. Continuations are somewhat analogous to a structured
* version of C's <code>setjmp/longjmp</code> (although they contain
* more state, so you might consider them closer to threads).
@ -1320,11 +1320,10 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta
* cont.call(args, ...)
* cont[args, ...]
*
* Invokes the continuation. The program continues from the end of the
* <code>callcc</code> block. If no arguments are given, the original
* <code>callcc</code> returns <code>nil</code>. If one argument is
* given, <code>callcc</code> returns it. Otherwise, an array
* containing <i>args</i> is returned.
* Invokes the continuation. The program continues from the end of
* the #callcc block. If no arguments are given, the original #callcc
* returns +nil+. If one argument is given, #callcc returns
* it. Otherwise, an array containing <i>args</i> is returned.
*
* callcc {|cont| cont.call } #=> nil
* callcc {|cont| cont.call 1 } #=> 1
@ -1376,10 +1375,10 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
* manpage to configure the size of the fiber stack(s).
*
* When a fiber is created it will not run automatically. Rather it must
* be explicitly asked to run using the <code>Fiber#resume</code> method.
* be explicitly asked to run using the Fiber#resume method.
* The code running inside the fiber can give up control by calling
* <code>Fiber.yield</code> in which case it yields control back to caller
* (the caller of the <code>Fiber#resume</code>).
* Fiber.yield in which case it yields control back to caller (the
* caller of the Fiber#resume).
*
* Upon yielding or termination the Fiber returns the value of the last
* executed expression
@ -1401,10 +1400,10 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
* 2
* FiberError: dead fiber called
*
* The <code>Fiber#resume</code> method accepts an arbitrary number of
* parameters, if it is the first call to <code>resume</code> then they
* will be passed as block arguments. Otherwise they will be the return
* value of the call to <code>Fiber.yield</code>
* The Fiber#resume method accepts an arbitrary number of parameters,
* if it is the first call to #resume then they will be passed as
* block arguments. Otherwise they will be the return value of the
* call to Fiber.yield
*
* Example:
*
@ -1946,16 +1945,16 @@ rb_fiber_alive_p(VALUE fibval)
* call-seq:
* fiber.resume(args, ...) -> obj
*
* Resumes the fiber from the point at which the last <code>Fiber.yield</code>
* was called, or starts running it if it is the first call to
* <code>resume</code>. Arguments passed to resume will be the value of
* the <code>Fiber.yield</code> expression or will be passed as block
* parameters to the fiber's block if this is the first <code>resume</code>.
* Resumes the fiber from the point at which the last Fiber.yield was
* called, or starts running it if it is the first call to
* #resume. Arguments passed to resume will be the value of the
* Fiber.yield expression or will be passed as block parameters to
* the fiber's block if this is the first #resume.
*
* Alternatively, when resume is called it evaluates to the arguments passed
* to the next <code>Fiber.yield</code> statement inside the fiber's block
* to the next Fiber.yield statement inside the fiber's block
* or to the block value if it runs to completion without any
* <code>Fiber.yield</code>
* Fiber.yield
*/
static VALUE
rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib)
@ -1970,7 +1969,7 @@ rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib)
* fiber.raise(exception [, string [, array]]) -> obj
*
* Raises an exception in the fiber at the point at which the last
* <code>Fiber.yield</code> was called, or at the start if neither +resume+
* Fiber.yield was called, or at the start if neither +resume+
* nor +raise+ were called before.
*
* With no arguments, raises a +RuntimeError+. With a single +String+
@ -1996,7 +1995,7 @@ rb_fiber_raise(int argc, VALUE *argv, VALUE fib)
* Transfer control to another fiber, resuming it from where it last
* stopped or starting it if it was not resumed before. The calling
* fiber will be suspended much like in a call to
* <code>Fiber.yield</code>. You need to <code>require 'fiber'</code>
* Fiber.yield. You need to <code>require 'fiber'</code>
* before using this method.
*
* The fiber which receives the transfer call is treats it much like
@ -2048,9 +2047,9 @@ rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fibval)
*
* Yields control back to the context that resumed the fiber, passing
* along any arguments that were passed to it. The fiber will resume
* processing at this point when <code>resume</code> is called next.
* Any arguments passed to the next <code>resume</code> will be the
* value that this <code>Fiber.yield</code> expression evaluates to.
* processing at this point when #resume is called next.
* Any arguments passed to the next #resume will be the value that
* this Fiber.yield expression evaluates to.
*/
static VALUE
rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass)

49
dir.c
View file

@ -592,11 +592,10 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
* The optional <i>encoding</i> keyword argument specifies the encoding of the directory.
* If not specified, the filesystem encoding is used.
*
* With no block, <code>open</code> is a synonym for
* <code>Dir::new</code>. If a block is present, it is passed
* <i>aDir</i> as a parameter. The directory is closed at the end of
* the block, and <code>Dir::open</code> returns the value of the
* block.
* With no block, <code>open</code> is a synonym for Dir::new. If a
* block is present, it is passed <i>aDir</i> as a parameter. The
* directory is closed at the end of the block, and Dir::open returns
* the value of the block.
*/
static VALUE
dir_s_open(int argc, VALUE *argv, VALUE klass)
@ -870,8 +869,7 @@ dir_each_entry(VALUE dir, VALUE (*each)(VALUE, VALUE), VALUE arg, int children_o
* dir.pos -> integer
* dir.tell -> integer
*
* Returns the current position in <em>dir</em>. See also
* <code>Dir#seek</code>.
* Returns the current position in <em>dir</em>. See also Dir#seek.
*
* d = Dir.new("testdir")
* d.tell #=> 0
@ -898,7 +896,7 @@ dir_tell(VALUE dir)
* dir.seek( integer ) -> dir
*
* Seeks to a particular location in <em>dir</em>. <i>integer</i>
* must be a value returned by <code>Dir#tell</code>.
* must be a value returned by Dir#tell.
*
* d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
* d.read #=> "."
@ -926,8 +924,7 @@ dir_seek(VALUE dir, VALUE pos)
* call-seq:
* dir.pos = integer -> integer
*
* Synonym for <code>Dir#seek</code>, but returns the position
* parameter.
* Synonym for Dir#seek, but returns the position parameter.
*
* d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
* d.read #=> "."
@ -1044,8 +1041,8 @@ chdir_restore(struct chdir_data *args)
* Changes the current working directory of the process to the given
* string. When called without an argument, changes the directory to
* the value of the environment variable <code>HOME</code>, or
* <code>LOGDIR</code>. <code>SystemCallError</code> (probably
* <code>Errno::ENOENT</code>) if the target directory does not exist.
* <code>LOGDIR</code>. SystemCallError (probably Errno::ENOENT) if
* the target directory does not exist.
*
* If a block is given, it is passed the name of the new current
* directory, and the block is executed with that as the current
@ -1242,11 +1239,10 @@ nogvl_mkdir(void *ptr)
*
* Makes a new directory named by <i>string</i>, with permissions
* specified by the optional parameter <i>anInteger</i>. The
* permissions may be modified by the value of
* <code>File::umask</code>, and are ignored on NT. Raises a
* <code>SystemCallError</code> if the directory cannot be created. See
* also the discussion of permissions in the class documentation for
* <code>File</code>.
* permissions may be modified by the value of File::umask, and are
* ignored on NT. Raises a SystemCallError if the directory cannot be
* created. See also the discussion of permissions in the class
* documentation for File.
*
* Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0
*
@ -1288,8 +1284,8 @@ nogvl_rmdir(void *ptr)
* Dir.rmdir( string ) -> 0
* Dir.unlink( string ) -> 0
*
* Deletes the named directory. Raises a subclass of
* <code>SystemCallError</code> if the directory isn't empty.
* Deletes the named directory. Raises a subclass of SystemCallError
* if the directory isn't empty.
*/
static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
@ -2974,8 +2970,8 @@ dir_collect(VALUE dir)
* Dir.entries( dirname, encoding: enc ) -> array
*
* Returns an array containing all of the filenames in the given
* directory. Will raise a <code>SystemCallError</code> if the named
* directory doesn't exist.
* directory. Will raise a SystemCallError if the named directory
* doesn't exist.
*
* The optional <i>encoding</i> keyword argument specifies the encoding of the
* directory. If not specified, the filesystem encoding is used.
@ -3082,8 +3078,8 @@ dir_collect_children(VALUE dir)
* Dir.children( dirname, encoding: enc ) -> array
*
* Returns an array containing all of the filenames except for "."
* and ".." in the given directory. Will raise a
* <code>SystemCallError</code> if the named directory doesn't exist.
* and ".." in the given directory. Will raise a SystemCallError if
* the named directory doesn't exist.
*
* The optional <i>encoding</i> keyword argument specifies the encoding of the
* directory. If not specified, the filesystem encoding is used.
@ -3390,10 +3386,9 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
}
/*
* Objects of class <code>Dir</code> are directory streams representing
* directories in the underlying file system. They provide a variety of
* ways to list directories and their contents. See also
* <code>File</code>.
* Objects of class Dir are directory streams representing
* directories in the underlying file system. They provide a variety
* of ways to list directories and their contents. See also File.
*
* The directory used in these examples contains the two regular files
* (<code>config.h</code> and <code>main.rb</code>), the parent

View file

@ -1756,11 +1756,11 @@ rb_enc_aliases(VALUE klass)
* "some string".encode "ISO-8859-1"
* #=> "some string"
*
* <code>Encoding::ASCII_8BIT</code> is a special encoding that is usually
* used for a byte string, not a character string. But as the name insists,
* its characters in the range of ASCII are considered as ASCII characters.
* This is useful when you use ASCII-8BIT characters with other ASCII
* compatible characters.
* Encoding::ASCII_8BIT is a special encoding that is usually used for
* a byte string, not a character string. But as the name insists, its
* characters in the range of ASCII are considered as ASCII
* characters. This is useful when you use ASCII-8BIT characters with
* other ASCII compatible characters.
*
* == Changing an encoding
*
@ -1798,11 +1798,12 @@ rb_enc_aliases(VALUE klass)
* All Ruby script code has an associated Encoding which any String literal
* created in the source code will be associated to.
*
* The default script encoding is <code>Encoding::UTF-8</code> after v2.0, but it can
* be changed by a magic comment on the first line of the source code file (or
* second line, if there is a shebang line on the first). The comment must
* contain the word <code>coding</code> or <code>encoding</code>, followed
* by a colon, space and the Encoding name or alias:
* The default script encoding is Encoding::UTF_8 after v2.0, but it
* can be changed by a magic comment on the first line of the source
* code file (or second line, if there is a shebang line on the
* first). The comment must contain the word <code>coding</code> or
* <code>encoding</code>, followed by a colon, space and the Encoding
* name or alias:
*
* # encoding: UTF-8
*

51
enum.c
View file

@ -1123,10 +1123,10 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
* %w{apple pear fig}.sort_by { |word| word.length }
* #=> ["fig", "pear", "apple"]
*
* The current implementation of <code>sort_by</code> generates an
* array of tuples containing the original collection element and the
* mapped value. This makes <code>sort_by</code> fairly expensive when
* the keysets are simple.
* The current implementation of #sort_by generates an array of
* tuples containing the original collection element and the mapped
* value. This makes #sort_by fairly expensive when the keysets are
* simple.
*
* require 'benchmark'
*
@ -1145,15 +1145,15 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
*
* However, consider the case where comparing the keys is a non-trivial
* operation. The following code sorts some files on modification time
* using the basic <code>sort</code> method.
* using the basic #sort method.
*
* files = Dir["*"]
* sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime }
* sorted #=> ["mon", "tues", "wed", "thurs"]
*
* This sort is inefficient: it generates two new <code>File</code>
* This sort is inefficient: it generates two new File
* objects during every comparison. A slightly better technique is to
* use the <code>Kernel#test</code> method to generate the modification
* use the Kernel#test method to generate the modification
* times directly.
*
* files = Dir["*"]
@ -1162,20 +1162,20 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
* }
* sorted #=> ["mon", "tues", "wed", "thurs"]
*
* This still generates many unnecessary <code>Time</code> objects. A
* more efficient technique is to cache the sort keys (modification
* times in this case) before the sort. Perl users often call this
* approach a Schwartzian transform, after Randal Schwartz. We
* construct a temporary array, where each element is an array
* containing our sort key along with the filename. We sort this array,
* and then extract the filename from the result.
* This still generates many unnecessary Time objects. A more
* efficient technique is to cache the sort keys (modification times
* in this case) before the sort. Perl users often call this approach
* a Schwartzian transform, after Randal Schwartz. We construct a
* temporary array, where each element is an array containing our
* sort key along with the filename. We sort this array, and then
* extract the filename from the result.
*
* sorted = Dir["*"].collect { |f|
* [test(?M, f), f]
* }.sort.collect { |f| f[1] }
* sorted #=> ["mon", "tues", "wed", "thurs"]
*
* This is exactly what <code>sort_by</code> does internally.
* This is exactly what #sort_by does internally.
*
* sorted = Dir["*"].sort_by { |f| test(?M, f) }
* sorted #=> ["mon", "tues", "wed", "thurs"]
@ -1716,7 +1716,7 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
* enum.min(n) { |a, b| block } -> array
*
* Returns the object in _enum_ with the minimum value. The
* first form assumes all objects implement <code>Comparable</code>;
* first form assumes all objects implement Comparable;
* the second uses the block to return <em>a <=> b</em>.
*
* a = %w(albatross dog horse)
@ -1808,7 +1808,7 @@ max_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
* enum.max(n) { |a, b| block } -> array
*
* Returns the object in _enum_ with the maximum value. The
* first form assumes all objects implement <code>Comparable</code>;
* first form assumes all objects implement Comparable;
* the second uses the block to return <em>a <=> b</em>.
*
* a = %w(albatross dog horse)
@ -1967,7 +1967,7 @@ minmax_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, _memo))
*
* Returns a two element array which contains the minimum and the
* maximum value in the enumerable. The first form assumes all
* objects implement <code>Comparable</code>; the second uses the
* objects implement Comparable; the second uses the
* block to return <em>a <=> b</em>.
*
* a = %w(albatross dog horse)
@ -4070,14 +4070,13 @@ enum_uniq(VALUE obj)
}
/*
* The <code>Enumerable</code> mixin provides collection classes with
* several traversal and searching methods, and with the ability to
* sort. The class must provide a method <code>each</code>, which
* yields successive members of the collection. If
* <code>Enumerable#max</code>, <code>#min</code>, or
* <code>#sort</code> is used, the objects in the collection must also
* implement a meaningful <code><=></code> operator, as these methods
* rely on an ordering between members of the collection.
* The Enumerable mixin provides collection classes with several
* traversal and searching methods, and with the ability to sort. The
* class must provide a method #each, which yields
* successive members of the collection. If Enumerable#max, #min, or
* #sort is used, the objects in the collection must also implement a
* meaningful <code><=></code> operator, as these methods rely on an
* ordering between members of the collection.
*/
void

42
error.c
View file

@ -155,7 +155,7 @@ rb_warning_s_warn(VALUE mod, VALUE str)
* Document-module: Warning
*
* The Warning module contains a single method named #warn, and the
* module extends itself, making <code>Warning.warn</code> available.
* module extends itself, making Warning.warn available.
* Warning.warn is called for all warnings issued by Ruby.
* By default, warnings are printed to $stderr.
*
@ -306,7 +306,7 @@ warning_write(int argc, VALUE *argv, VALUE buf)
* <code>-W0</code> flag), does nothing. Otherwise,
* converts each of the messages to strings, appends a newline
* character to the string if the string does not end in a newline,
* and calls <code>Warning.warn</code> with the string.
* and calls Warning.warn with the string.
*
* warn("warning 1", "warning 2")
*
@ -1266,7 +1266,7 @@ try_convert_to_exception(VALUE obj)
* call-seq:
* exc == obj -> true or false
*
* Equality---If <i>obj</i> is not an <code>Exception</code>, returns
* Equality---If <i>obj</i> is not an Exception, returns
* <code>false</code>. Otherwise, returns <code>true</code> if <i>exc</i> and
* <i>obj</i> share same class, messages, and backtrace.
*/
@ -1442,7 +1442,7 @@ name_err_init_attr(VALUE exc, VALUE recv, VALUE method)
* NameError.new(msg=nil, name=nil, receiver: nil) -> name_error
*
* Construct a new NameError exception. If given the <i>name</i>
* parameter may subsequently be examined using the <code>NameError#name</code>
* parameter may subsequently be examined using the NameError#name
* method. <i>receiver</i> parameter allows to pass object in
* context of which the error happened. Example:
*
@ -1852,19 +1852,18 @@ syntax_error_initialize(int argc, VALUE *argv, VALUE self)
/*
* Document-module: Errno
*
* Ruby exception objects are subclasses of <code>Exception</code>.
* However, operating systems typically report errors using plain
* integers. Module <code>Errno</code> is created dynamically to map
* these operating system errors to Ruby classes, with each error
* number generating its own subclass of <code>SystemCallError</code>.
* As the subclass is created in module <code>Errno</code>, its name
* will start <code>Errno::</code>.
* Ruby exception objects are subclasses of Exception. However,
* operating systems typically report errors using plain
* integers. Module Errno is created dynamically to map these
* operating system errors to Ruby classes, with each error number
* generating its own subclass of SystemCallError. As the subclass
* is created in module Errno, its name will start
* <code>Errno::</code>.
*
* The names of the <code>Errno::</code> classes depend on
* the environment in which Ruby runs. On a typical Unix or Windows
* platform, there are <code>Errno</code> classes such as
* <code>Errno::EACCES</code>, <code>Errno::EAGAIN</code>,
* <code>Errno::EINTR</code>, and so on.
* The names of the <code>Errno::</code> classes depend on the
* environment in which Ruby runs. On a typical Unix or Windows
* platform, there are Errno classes such as Errno::EACCES,
* Errno::EAGAIN, Errno::EINTR, and so on.
*
* The integer operating system error number corresponding to a
* particular error is available as the class constant
@ -1875,7 +1874,7 @@ syntax_error_initialize(int argc, VALUE *argv, VALUE self)
* Errno::EINTR::Errno #=> 4
*
* The full list of operating system errors on your particular platform
* are available as the constants of <code>Errno</code>.
* are available as the constants of Errno.
*
* Errno.constants #=> :E2BIG, :EACCES, :EADDRINUSE, :EADDRNOTAVAIL, ...
*/
@ -1934,11 +1933,10 @@ get_syserr(int n)
* call-seq:
* SystemCallError.new(msg, errno) -> system_call_error_subclass
*
* If _errno_ corresponds to a known system error code, constructs
* the appropriate <code>Errno</code> class for that error, otherwise
* constructs a generic <code>SystemCallError</code> object. The
* error number is subsequently available via the <code>errno</code>
* method.
* If _errno_ corresponds to a known system error code, constructs the
* appropriate Errno class for that error, otherwise constructs a
* generic SystemCallError object. The error number is subsequently
* available via the #errno method.
*/
static VALUE

36
eval.c
View file

@ -714,7 +714,7 @@ extract_raise_opts(int argc, const VALUE *argv, VALUE *opts)
* fail(exception [, string [, array]], cause: $!)
*
* With no arguments, raises the exception in <code>$!</code> or raises
* a <code>RuntimeError</code> if <code>$!</code> is +nil+.
* a RuntimeError if <code>$!</code> is +nil+.
* With a single +String+ argument, raises a
* +RuntimeError+ with the string as a message. Otherwise,
* the first parameter should be the name of an +Exception+
@ -1200,11 +1200,11 @@ rb_frame_last_func(void)
* append_features(mod) -> mod
*
* When this module is included in another, Ruby calls
* <code>append_features</code> in this module, passing it the
* receiving module in _mod_. Ruby's default implementation is
* to add the constants, methods, and module variables of this module
* to _mod_ if this module has not already been added to
* _mod_ or one of its ancestors. See also <code>Module#include</code>.
* #append_features in this module, passing it the receiving module
* in _mod_. Ruby's default implementation is to add the constants,
* methods, and module variables of this module to _mod_ if this
* module has not already been added to _mod_ or one of its
* ancestors. See also Module#include.
*/
static VALUE
@ -1222,7 +1222,7 @@ rb_mod_append_features(VALUE module, VALUE include)
* call-seq:
* include(module, ...) -> self
*
* Invokes <code>Module.append_features</code> on each parameter in reverse order.
* Invokes Module.append_features on each parameter in reverse order.
*/
static VALUE
@ -1249,11 +1249,11 @@ rb_mod_include(int argc, VALUE *argv, VALUE module)
* prepend_features(mod) -> mod
*
* When this module is prepended in another, Ruby calls
* <code>prepend_features</code> in this module, passing it the
* receiving module in _mod_. Ruby's default implementation is
* to overlay the constants, methods, and module variables of this module
* to _mod_ if this module has not already been added to
* _mod_ or one of its ancestors. See also <code>Module#prepend</code>.
* #prepend_features in this module, passing it the receiving module
* in _mod_. Ruby's default implementation is to overlay the
* constants, methods, and module variables of this module to _mod_
* if this module has not already been added to _mod_ or one of its
* ancestors. See also Module#prepend.
*/
static VALUE
@ -1271,7 +1271,7 @@ rb_mod_prepend_features(VALUE module, VALUE prepend)
* call-seq:
* prepend(module, ...) -> self
*
* Invokes <code>Module.prepend_features</code> on each parameter in reverse order.
* Invokes Module.prepend_features on each parameter in reverse order.
*/
static VALUE
@ -1646,7 +1646,7 @@ rb_extend_object(VALUE obj, VALUE module)
*
* Extends the specified object by adding this module's constants and
* methods (which are added as singleton methods). This is the callback
* method used by <code>Object#extend</code>.
* method used by Object#extend.
*
* module Picky
* def Picky.extend_object(o)
@ -1722,9 +1722,9 @@ rb_obj_extend(int argc, VALUE *argv, VALUE obj)
* call-seq:
* include(module, ...) -> self
*
* Invokes <code>Module.append_features</code>
* on each parameter in turn. Effectively adds the methods and constants
* in each module to the receiver.
* Invokes Module.append_features on each parameter in turn.
* Effectively adds the methods and constants in each module to the
* receiver.
*/
static VALUE
@ -1744,7 +1744,7 @@ top_include(int argc, VALUE *argv, VALUE self)
* using(module) -> self
*
* Import class refinements from <i>module</i> into the scope where
* <code>using</code> is called.
* #using is called.
*/
static VALUE

112
file.c
View file

@ -431,8 +431,8 @@ apply2files(int (*func)(const char *, void *), int argc, VALUE *argv, void *arg)
* For instance, the pathname becomes void when the file has been
* moved or deleted.
*
* This method raises <code>IOError</code> for a <i>file</i> created using
* <code>File::Constants::TMPFILE</code> because they don't have a pathname.
* This method raises IOError for a <i>file</i> created using
* File::Constants::TMPFILE because they don't have a pathname.
*
* File.new("testfile").path #=> "testfile"
* File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx"
@ -912,7 +912,7 @@ typedef struct stat statx_data;
* stat.atime -> time
*
* Returns the last access time for this file as an object of class
* <code>Time</code>.
* Time.
*
* File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
*
@ -1248,8 +1248,7 @@ rb_stat(VALUE file, struct stat *st)
* call-seq:
* File.stat(file_name) -> stat
*
* Returns a <code>File::Stat</code> object for the named file (see
* <code>File::Stat</code>).
* Returns a File::Stat object for the named file (see File::Stat).
*
* File.stat("testfile").mtime #=> Tue Apr 08 12:58:04 CDT 2003
*
@ -1273,7 +1272,7 @@ rb_file_s_stat(VALUE klass, VALUE fname)
* ios.stat -> stat
*
* Returns status information for <em>ios</em> as an object of type
* <code>File::Stat</code>.
* File::Stat.
*
* f = File.new("testfile")
* s = f.stat
@ -1321,8 +1320,8 @@ lstat_without_gvl(const char *path, struct stat *st)
* call-seq:
* File.lstat(file_name) -> stat
*
* Same as <code>File::stat</code>, but does not follow the last symbolic
* link. Instead, reports on the link itself.
* Same as File::stat, but does not follow the last symbolic link.
* Instead, reports on the link itself.
*
* File.symlink("testfile", "link2test") #=> 0
* File.stat("testfile").size #=> 66
@ -1352,8 +1351,8 @@ rb_file_s_lstat(VALUE klass, VALUE fname)
* call-seq:
* file.lstat -> stat
*
* Same as <code>IO#stat</code>, but does not follow the last symbolic
* link. Instead, reports on the link itself.
* Same as IO#stat, but does not follow the last symbolic link.
* Instead, reports on the link itself.
*
* File.symlink("testfile", "link2test") #=> 0
* File.stat("testfile").size #=> 66
@ -1533,10 +1532,10 @@ rb_access(VALUE fname, int mode)
/*
* Document-class: FileTest
*
* <code>FileTest</code> implements file test operations similar to
* those used in <code>File::Stat</code>. It exists as a standalone
* module, and its methods are also insinuated into the <code>File</code>
* class. (Note that this is not done by inclusion: the interpreter cheats).
* FileTest implements file test operations similar to those used in
* File::Stat. It exists as a standalone module, and its methods are
* also insinuated into the File class. (Note that this is not done
* by inclusion: the interpreter cheats).
*
*/
@ -2266,8 +2265,8 @@ rb_file_s_atime(VALUE klass, VALUE fname)
* call-seq:
* file.atime -> time
*
* Returns the last access time (a <code>Time</code> object)
* for <i>file</i>, or epoch if <i>file</i> has not been accessed.
* Returns the last access time (a Time object) for <i>file</i>, or
* epoch if <i>file</i> has not been accessed.
*
* File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
*
@ -2512,7 +2511,7 @@ rb_file_s_chmod(int argc, VALUE *argv)
* Changes permission bits on <i>file</i> to the bit pattern
* represented by <i>mode_int</i>. Actual effects are platform
* dependent; on Unix systems, see <code>chmod(2)</code> for details.
* Follows symbolic links. Also see <code>File#lchmod</code>.
* Follows symbolic links. Also see File#lchmod.
*
* f = File.new("out", "w");
* f.chmod(0644) #=> 0
@ -2560,9 +2559,9 @@ lchmod_internal(const char *path, void *mode)
* call-seq:
* File.lchmod(mode_int, file_name, ...) -> integer
*
* Equivalent to <code>File::chmod</code>, but does not follow symbolic
* links (so it will change the permissions associated with the link,
* not the file referenced by the link). Often not available.
* Equivalent to File::chmod, but does not follow symbolic links (so
* it will change the permissions associated with the link, not the
* file referenced by the link). Often not available.
*
*/
@ -2646,7 +2645,7 @@ rb_file_s_chown(int argc, VALUE *argv)
* change the owner of a file. The current owner of a file may change
* the file's group to any group to which the owner belongs. A
* <code>nil</code> or -1 owner or group id is ignored. Follows
* symbolic links. See also <code>File#lchown</code>.
* symbolic links. See also File#lchown.
*
* File.new("testfile").chown(502, 1000)
*
@ -2690,7 +2689,7 @@ lchown_internal(const char *path, void *arg)
* call-seq:
* File.lchown(owner_int, group_int, file_name,..) -> integer
*
* Equivalent to <code>File::chown</code>, but does not follow symbolic
* Equivalent to File::chown, but does not follow symbolic
* links (so it will change the owner associated with the link, not the
* file referenced by the link). Often not available. Returns number
* of files in the argument list.
@ -2942,7 +2941,7 @@ syserr_fail2_in(const char *func, int e, VALUE s1, VALUE s2)
*
* Creates a new name for an existing file using a hard link. Will not
* overwrite <i>new_name</i> if it already exists (raising a subclass
* of <code>SystemCallError</code>). Not available on all platforms.
* of SystemCallError). Not available on all platforms.
*
* File.link("testfile", ".testfile") #=> 0
* IO.readlines(".testfile")[0] #=> "This is line one\n"
@ -2971,7 +2970,7 @@ rb_file_s_link(VALUE klass, VALUE from, VALUE to)
* File.symlink(old_name, new_name) -> 0
*
* Creates a symbolic link called <i>new_name</i> for the existing file
* <i>old_name</i>. Raises a <code>NotImplemented</code> exception on
* <i>old_name</i>. Raises a NotImplemented exception on
* platforms that do not support symbolic links.
*
* File.symlink("testfile", "link2test") #=> 0
@ -3091,9 +3090,9 @@ unlink_internal(const char *path, void *arg)
* <code>unlink(2)</code> system call, the type of
* exception raised depends on its error type (see
* https://linux.die.net/man/2/unlink) and has the form of
* e.g. <code>Errno::ENOENT</code>.
* e.g. Errno::ENOENT.
*
* See also <code>Dir::rmdir</code>.
* See also Dir::rmdir.
*/
static VALUE
@ -3119,8 +3118,8 @@ no_gvl_rename(void *ptr)
* call-seq:
* File.rename(old_name, new_name) -> 0
*
* Renames the given file to the new name. Raises a
* <code>SystemCallError</code> if the file cannot be renamed.
* Renames the given file to the new name. Raises a SystemCallError
* if the file cannot be renamed.
*
* File.rename("afile", "afile.bak") #=> 0
*/
@ -4429,12 +4428,11 @@ ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encodin
*
* Returns the last component of the filename given in
* <i>file_name</i> (after first stripping trailing separators),
* which can be formed using both <code>File::SEPARATOR</code> and
* <code>File::ALT_SEPARATOR</code> as the separator when
* <code>File::ALT_SEPARATOR</code> is not <code>nil</code>. If
* <i>suffix</i> is given and present at the end of <i>file_name</i>,
* it is removed. If <i>suffix</i> is ".*", any extension will be
* removed.
* which can be formed using both File::SEPARATOR and
* File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is
* not <code>nil</code>. If <i>suffix</i> is given and present at the
* end of <i>file_name</i>, it is removed. If <i>suffix</i> is ".*",
* any extension will be removed.
*
* File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb"
* File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
@ -4492,9 +4490,9 @@ rb_file_s_basename(int argc, VALUE *argv)
*
* Returns all components of the filename given in <i>file_name</i>
* except the last one (after first stripping trailing separators).
* The filename can be formed using both <code>File::SEPARATOR</code>
* and <code>File::ALT_SEPARATOR</code> as the separator when
* <code>File::ALT_SEPARATOR</code> is not <code>nil</code>.
* The filename can be formed using both File::SEPARATOR and
* File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is
* not <code>nil</code>.
*
* File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work"
*/
@ -4676,8 +4674,8 @@ rb_file_s_path(VALUE klass, VALUE fname)
* File.split(file_name) -> array
*
* Splits the given string into a directory and a file component and
* returns them in a two-element array. See also
* <code>File::dirname</code> and <code>File::basename</code>.
* returns them in a two-element array. See also File::dirname and
* File::basename.
*
* File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
*/
@ -4957,9 +4955,9 @@ rb_thread_flock(void *data)
*
* Locks or unlocks a file according to <i>locking_constant</i> (a
* logical <em>or</em> of the values in the table below).
* Returns <code>false</code> if <code>File::LOCK_NB</code> is
* specified and the operation would otherwise have blocked. Not
* available on all platforms.
* Returns <code>false</code> if File::LOCK_NB is specified and the
* operation would otherwise have blocked. Not available on all
* platforms.
*
* Locking constants (in class File):
*
@ -5260,15 +5258,13 @@ rb_f_test(int argc, VALUE *argv)
/*
* Document-class: File::Stat
*
* Objects of class <code>File::Stat</code> encapsulate common status
* information for <code>File</code> objects. The information is
* recorded at the moment the <code>File::Stat</code> object is
* created; changes made to the file after that point will not be
* reflected. <code>File::Stat</code> objects are returned by
* <code>IO#stat</code>, <code>File::stat</code>,
* <code>File#lstat</code>, and <code>File::lstat</code>. Many of these
* Objects of class File::Stat encapsulate common status information
* for File objects. The information is recorded at the moment the
* File::Stat object is created; changes made to the file after that
* point will not be reflected. File::Stat objects are returned by
* IO#stat, File::stat, File#lstat, and File::lstat. Many of these
* methods return platform-specific values, and not all values are
* meaningful on all systems. See also <code>Kernel#test</code>.
* meaningful on all systems. See also Kernel#test.
*/
static VALUE
@ -5389,10 +5385,9 @@ rb_stat_p(VALUE obj)
*
* Returns <code>true</code> if <i>stat</i> is a symbolic link,
* <code>false</code> if it isn't or if the operating system doesn't
* support this feature. As <code>File::stat</code> automatically
* follows symbolic links, <code>symlink?</code> will always be
* <code>false</code> for an object returned by
* <code>File::stat</code>.
* support this feature. As File::stat automatically follows symbolic
* links, #symlink? will always be <code>false</code> for an object
* returned by File::stat.
*
* File.symlink("testfile", "alink") #=> 0
* File.stat("alink").symlink? #=> false
@ -6283,11 +6278,10 @@ const char ruby_null_device[] =
;
/*
* A <code>File</code> is an abstraction of any file object accessible
* by the program and is closely associated with class <code>IO</code>.
* <code>File</code> includes the methods of module
* <code>FileTest</code> as class methods, allowing you to write (for
* example) <code>File.exist?("foo")</code>.
* A File is an abstraction of any file object accessible by the
* program and is closely associated with class IO. File includes
* the methods of module FileTest as class methods, allowing you to
* write (for example) <code>File.exist?("foo")</code>.
*
* In the description of File methods,
* <em>permission bits</em> are a platform-specific

6
gc.c
View file

@ -2692,9 +2692,9 @@ os_obj_of(VALUE of)
* <i>module</i>. Returns the number of objects found. Immediate
* objects (<code>Fixnum</code>s, <code>Symbol</code>s
* <code>true</code>, <code>false</code>, and <code>nil</code>) are
* never returned. In the example below, <code>each_object</code>
* returns both the numbers we defined and several constants defined in
* the <code>Math</code> module.
* never returned. In the example below, #each_object returns both
* the numbers we defined and several constants defined in the Math
* module.
*
* If no block is given, an enumerator is returned instead.
*

37
hash.c
View file

@ -1703,9 +1703,9 @@ rb_hash_rehash_i(VALUE key, VALUE value, VALUE arg)
*
* Rebuilds the hash based on the current hash values for each key. If
* values of key objects have changed since they were inserted, this
* method will reindex <i>hsh</i>. If <code>Hash#rehash</code> is
* method will reindex <i>hsh</i>. If Hash#rehash is
* called while an iterator is traversing the hash, a
* <code>RuntimeError</code> will be raised in the iterator.
* RuntimeError will be raised in the iterator.
*
* a = [ "a", "b" ]
* c = [ "c", "d" ]
@ -1788,7 +1788,7 @@ rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval)
*
* Element Reference---Retrieves the <i>value</i> object corresponding
* to the <i>key</i> object. If not found, returns the default value (see
* <code>Hash::new</code> for details).
* Hash::new for details).
*
* h = { "a" => 100, "b" => 200 }
* h["a"] #=> 100
@ -1835,7 +1835,7 @@ rb_hash_lookup(VALUE hash, VALUE key)
*
* Returns a value from the hash for the given key. If the key can't be
* found, there are several options: With no other arguments, it will
* raise a <code>KeyError</code> exception; if <i>default</i> is given,
* raise a KeyError exception; if <i>default</i> is given,
* then that will be returned; if the optional code block is specified,
* then that will be run and its result returned.
*
@ -1905,7 +1905,7 @@ rb_hash_fetch(VALUE hash, VALUE key)
*
* Returns the default value, the value that would be returned by
* <i>hsh</i>[<i>key</i>] if <i>key</i> did not exist in <i>hsh</i>.
* See also <code>Hash::new</code> and <code>Hash#default=</code>.
* See also Hash::new and Hash#default=.
*
* h = Hash.new #=> {}
* h.default #=> nil
@ -1942,7 +1942,7 @@ rb_hash_default(int argc, VALUE *argv, VALUE hash)
*
* Sets the default value, the value returned for a key that does not
* exist in the hash. It is not possible to set the default to a
* <code>Proc</code> that will be executed on each key lookup.
* Proc that will be executed on each key lookup.
*
* h = { "a" => 100, "b" => 200 }
* h.default = "Go fish"
@ -1968,7 +1968,7 @@ rb_hash_set_default(VALUE hash, VALUE ifnone)
* call-seq:
* hsh.default_proc -> anObject
*
* If <code>Hash::new</code> was invoked with a block, return that
* If Hash::new was invoked with a block, return that
* block, otherwise return <code>nil</code>.
*
* h = Hash.new {|h,k| h[k] = k*k } #=> {}
@ -2268,7 +2268,7 @@ rb_hash_delete_if(VALUE hash)
* hsh.reject! {| key, value | block } -> hsh or nil
* hsh.reject! -> an_enumerator
*
* Equivalent to <code>Hash#delete_if</code>, but returns
* Equivalent to Hash#delete_if, but returns
* <code>nil</code> if no changes were made.
*/
@ -2365,7 +2365,7 @@ rb_hash_slice(int argc, VALUE *argv, VALUE hash)
* hsh.values_at(key, ...) -> array
*
* Return an array containing the values associated with the given keys.
* Also see <code>Hash.select</code>.
* Also see Hash.select.
*
* h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
* h.values_at("cow", "cat") #=> ["bovine", "feline"]
@ -2389,8 +2389,8 @@ rb_hash_values_at(int argc, VALUE *argv, VALUE hash)
* hsh.fetch_values(key, ...) { |key| block } -> array
*
* Returns an array containing the values associated with the given keys
* but also raises <code>KeyError</code> when one of keys can't be found.
* Also see <code>Hash#values_at</code> and <code>Hash#fetch</code>.
* but also raises KeyError when one of keys can't be found.
* Also see Hash#values_at and Hash#fetch.
*
* h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
*
@ -3188,7 +3188,7 @@ keys_i(VALUE key, VALUE value, VALUE ary)
* hsh.keys -> array
*
* Returns a new array populated with the keys from this hash. See also
* <code>Hash#values</code>.
* Hash#values.
*
* h = { "a" => 100, "b" => 200, "c" => 300, "d" => 400 }
* h.keys #=> ["a", "b", "c", "d"]
@ -3235,7 +3235,7 @@ values_i(VALUE key, VALUE value, VALUE ary)
* hsh.values -> array
*
* Returns a new array populated with the values from <i>hsh</i>. See
* also <code>Hash#keys</code>.
* also Hash#keys.
*
* h = { "a" => 100, "b" => 200, "c" => 300 }
* h.values #=> [100, 200, 300]
@ -3287,7 +3287,7 @@ rb_hash_values(VALUE hash)
* h.has_key?("a") #=> true
* h.has_key?("z") #=> false
*
* Note that <code>include?</code> and <code>member?</code> do not test member
* Note that #include? and #member? do not test member
* equality using <code>==</code> as do other Enumerables.
*
* See also Enumerable#include?
@ -3427,8 +3427,7 @@ hash_equal(VALUE hash1, VALUE hash2, int eql)
*
* Equality---Two hashes are equal if they each contain the same number
* of keys and if each key-value pair is equal to (according to
* <code>Object#==</code>) the corresponding elements in the other
* hash.
* Object#==) the corresponding elements in the other hash.
*
* h1 = { "a" => 1, "c" => 2 }
* h2 = { 7 => 35, "c" => 2, "a" => 1 }
@ -3796,7 +3795,7 @@ assoc_i(VALUE key, VALUE val, VALUE arg)
*
* Searches through the hash comparing _obj_ with the key using <code>==</code>.
* Returns the key-value pair (two elements array) or +nil+
* if no match is found. See <code>Array#assoc</code>.
* if no match is found. See Array#assoc.
*
* h = {"colors" => ["red", "blue", "green"],
* "letters" => ["a", "b", "c" ]}
@ -3858,7 +3857,7 @@ rassoc_i(VALUE key, VALUE val, VALUE arg)
*
* Searches through the hash comparing _obj_ with the value using <code>==</code>.
* Returns the first key-value pair (two-element array) that matches. See
* also <code>Array#rassoc</code>.
* also Array#rassoc.
*
* a = {1=> "one", 2 => "two", 3 => "three", "ii" => "two"}
* a.rassoc("two") #=> [2, "two"]
@ -4048,7 +4047,7 @@ rb_hash_compare_by_id(VALUE hash)
* hsh.compare_by_identity? -> true or false
*
* Returns <code>true</code> if <i>hsh</i> will compare its keys by
* their identity. Also see <code>Hash#compare_by_identity</code>.
* their identity. Also see Hash#compare_by_identity.
*
*/

328
io.c
View file

@ -2003,7 +2003,7 @@ static void clear_readconv(rb_io_t *fptr);
* ios.rewind -> 0
*
* Positions <em>ios</em> to the beginning of input, resetting
* <code>lineno</code> to zero.
* #lineno to zero.
*
* f = File.new("testfile")
* f.readline #=> "This is line one\n"
@ -2089,14 +2089,14 @@ io_fillbuf(rb_io_t *fptr)
*
* Returns true if <em>ios</em> is at end of file that means
* there are no more data to read.
* The stream must be opened for reading or an <code>IOError</code> will be
* The stream must be opened for reading or an IOError will be
* raised.
*
* f = File.new("testfile")
* dummy = f.readlines
* f.eof #=> true
*
* If <em>ios</em> is a stream such as pipe or socket, <code>IO#eof?</code>
* If <em>ios</em> is a stream such as pipe or socket, IO#eof?
* blocks until the other end sends some data or closes it.
*
* r, w = IO.pipe
@ -2110,10 +2110,9 @@ io_fillbuf(rb_io_t *fptr)
* r, w = IO.pipe
* r.eof? # blocks forever
*
* Note that <code>IO#eof?</code> reads data to the input byte buffer.
* So <code>IO#sysread</code> may not behave as you intend with
* <code>IO#eof?</code>, unless you call <code>IO#rewind</code>
* first (which is not available for some streams).
* Note that IO#eof? reads data to the input byte buffer. So
* IO#sysread may not behave as you intend with IO#eof?, unless you
* call IO#rewind first (which is not available for some streams).
*/
VALUE
@ -2145,7 +2144,7 @@ rb_io_eof(VALUE io)
* Returns the current ``sync mode'' of <em>ios</em>. When sync mode is
* true, all output is immediately flushed to the underlying operating
* system and is not buffered by Ruby internally. See also
* <code>IO#fsync</code>.
* IO#fsync.
*
* f = File.new("testfile")
* f.sync #=> false
@ -2170,7 +2169,7 @@ rb_io_sync(VALUE io)
* Sets the ``sync mode'' to <code>true</code> or <code>false</code>.
* When sync mode is true, all output is immediately flushed to the
* underlying operating system and is not buffered internally. Returns
* the new state. See also <code>IO#fsync</code>.
* the new state. See also IO#fsync.
*
* f = File.new("testfile")
* f.sync = true
@ -2197,12 +2196,11 @@ rb_io_set_sync(VALUE io, VALUE sync)
* ios.fsync -> 0 or nil
*
* Immediately writes all buffered data in <em>ios</em> to disk.
* Note that <code>fsync</code> differs from
* using <code>IO#sync=</code>. The latter ensures that data is flushed
* from Ruby's buffers, but does not guarantee that the underlying
* operating system actually writes it to disk.
* Note that #fsync differs from using IO#sync=. The latter ensures
* that data is flushed from Ruby's buffers, but does not guarantee
* that the underlying operating system actually writes it to disk.
*
* <code>NotImplementedError</code> is raised
* NotImplementedError is raised
* if the underlying operating system does not support <em>fsync(2)</em>.
*/
@ -2251,8 +2249,8 @@ nogvl_fdatasync(void *ptr)
* Immediately writes all buffered data in <em>ios</em> to disk.
*
* If the underlying operating system does not support <em>fdatasync(2)</em>,
* <code>IO#fsync</code> is called instead (which might raise a
* <code>NotImplementedError</code>).
* IO#fsync is called instead (which might raise a
* NotImplementedError).
*/
static VALUE
@ -2305,7 +2303,7 @@ rb_io_fileno(VALUE io)
* ios.pid -> integer
*
* Returns the process ID of a child process associated with
* <em>ios</em>. This will be set by <code>IO.popen</code>.
* <em>ios</em>. This will be set by IO.popen.
*
* pipe = IO.popen("-")
* if pipe
@ -2868,7 +2866,7 @@ io_getpartial(int argc, VALUE *argv, VALUE io, VALUE opts, int nonblock)
* The _outbuf_ will contain only the received data after the method call
* even if it is not empty at the beginning.
*
* It raises <code>EOFError</code> on end of file.
* It raises EOFError on end of file.
*
* readpartial is designed for streams such as pipe, socket, tty, etc.
* It blocks only when no data immediately available.
@ -3581,12 +3579,12 @@ rb_io_gets_internal(VALUE io)
* <i>sep</i>. A separator of +nil+ reads the entire
* contents, and a zero-length separator reads the input a paragraph at
* a time (two successive newlines in the input separate paragraphs).
* The stream must be opened for reading or an <code>IOError</code>
* will be raised. The line read in will be returned and also assigned
* to <code>$_</code>. Returns +nil+ if called at end of
* file. If the first argument is an integer, or optional second
* argument is given, the returning string would not be longer than the
* given value in bytes.
* The stream must be opened for reading or an IOError will be raised.
* The line read in will be returned and also assigned to
* <code>$_</code>. Returns +nil+ if called at end of file. If the
* first argument is an integer, or optional second argument is given,
* the returning string would not be longer than the given value in
* bytes.
*
* File.new("testfile").gets #=> "This is line one\n"
* $_ #=> "This is line one\n"
@ -3620,12 +3618,12 @@ rb_io_gets_m(int argc, VALUE *argv, VALUE io)
* ios.lineno -> integer
*
* Returns the current line number in <em>ios</em>. The stream must be
* opened for reading. <code>lineno</code> counts the number of times
* #gets is called rather than the number of newlines encountered. The two
* values will differ if #gets is called with a separator other than newline.
* opened for reading. #lineno counts the number of times #gets is called
* rather than the number of newlines encountered. The two values will
* differ if #gets is called with a separator other than newline.
*
* Methods that use <code>$/</code> like #each, #lines and #readline will
* also increment <code>lineno</code>.
* also increment #lineno.
*
* See also the <code>$.</code> variable.
*
@ -3681,8 +3679,7 @@ rb_io_set_lineno(VALUE io, VALUE lineno)
* ios.readline(limit [, getline_args]) -> string
* ios.readline(sep, limit [, getline_args]) -> string
*
* Reads a line as with <code>IO#gets</code>, but raises an
* <code>EOFError</code> on end of file.
* Reads a line as with IO#gets, but raises an EOFError on end of file.
*/
static VALUE
@ -3711,7 +3708,7 @@ static VALUE io_readlines(const struct getline_arg *arg, VALUE io);
* If the first argument is an integer, or an
* optional second argument is given, the returning string would not be
* longer than the given value in bytes. The stream must be opened for
* reading or an <code>IOError</code> will be raised.
* reading or an IOError will be raised.
*
* f = File.new("testfile")
* f.readlines[0] #=> "This is line one\n"
@ -3759,7 +3756,7 @@ io_readlines(const struct getline_arg *arg, VALUE io)
*
* 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.
* reading or an IOError will be raised.
*
* If no block is given, an enumerator is returned instead.
*
@ -3793,7 +3790,7 @@ rb_io_each_line(int argc, VALUE *argv, VALUE io)
}
/*
* This is a deprecated alias for <code>each_line</code>.
* This is a deprecated alias for #each_line.
*/
static VALUE
@ -3812,7 +3809,7 @@ rb_io_lines(int argc, VALUE *argv, VALUE io)
*
* 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.
* reading or an IOError will be raised.
*
* If no block is given, an enumerator is returned instead.
*
@ -3844,7 +3841,7 @@ rb_io_each_byte(VALUE io)
}
/*
* This is a deprecated alias for <code>each_byte</code>.
* This is a deprecated alias for #each_byte.
*/
static VALUE
@ -3970,7 +3967,7 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
*
* 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.
* reading or an IOError will be raised.
*
* If no block is given, an enumerator is returned instead.
*
@ -3998,7 +3995,7 @@ rb_io_each_char(VALUE io)
}
/*
* This is a deprecated alias for <code>each_char</code>.
* This is a deprecated alias for #each_char.
*/
static VALUE
@ -4018,9 +4015,9 @@ rb_io_chars(VALUE io)
* ios.each_codepoint -> an_enumerator
* ios.codepoints -> an_enumerator
*
* Passes the <code>Integer</code> ordinal of each character in <i>ios</i>,
* Passes the Integer ordinal of each character in <i>ios</i>,
* passing the codepoint as an argument. The stream must be opened for
* reading or an <code>IOError</code> will be raised.
* reading or an IOError will be raised.
*
* If no block is given, an enumerator is returned instead.
*
@ -4126,7 +4123,7 @@ rb_io_each_codepoint(VALUE io)
}
/*
* This is a deprecated alias for <code>each_codepoint</code>.
* This is a deprecated alias for #each_codepoint.
*/
static VALUE
@ -4170,7 +4167,7 @@ rb_io_getc(VALUE io)
* ios.readchar -> string
*
* Reads a one-character string from <em>ios</em>. Raises an
* <code>EOFError</code> on end of file.
* EOFError on end of file.
*
* f = File.new("testfile")
* f.readchar #=> "h"
@ -4229,8 +4226,8 @@ rb_io_getbyte(VALUE io)
* call-seq:
* ios.readbyte -> integer
*
* Reads a byte as with <code>IO#getbyte</code>, but raises an
* <code>EOFError</code> on end of file.
* Reads a byte as with IO#getbyte, but raises an EOFError on end of
* file.
*/
static VALUE
@ -4253,7 +4250,7 @@ rb_io_readbyte(VALUE io)
* such that a subsequent buffered read will return it. Only one byte
* may be pushed back before a subsequent read operation (that is,
* you will be able to read only the last of several bytes that have been pushed
* back). Has no effect with unbuffered reads (such as <code>IO#sysread</code>).
* back). Has no effect with unbuffered reads (such as IO#sysread).
*
* f = File.new("testfile") #=> #<File:testfile>
* b = f.getbyte #=> 0x38
@ -4292,7 +4289,7 @@ rb_io_ungetbyte(VALUE io, VALUE b)
* such that a subsequent buffered character read will return it. Only one character
* may be pushed back before a subsequent read operation (that is,
* you will be able to read only the last of several characters that have been pushed
* back). Has no effect with unbuffered reads (such as <code>IO#sysread</code>).
* back). Has no effect with unbuffered reads (such as IO#sysread).
*
* f = File.new("testfile") #=> #<File:testfile>
* c = f.getc #=> "8"
@ -4819,12 +4816,11 @@ rb_io_close(VALUE io)
*
* Closes <em>ios</em> and flushes any pending writes to the operating
* system. The stream is unavailable for any further data operations;
* an <code>IOError</code> is raised if such an attempt is made. I/O
* streams are automatically closed when they are claimed by the
* garbage collector.
* an IOError is raised if such an attempt is made. I/O streams are
* automatically closed when they are claimed by the garbage collector.
*
* If <em>ios</em> is opened by <code>IO.popen</code>,
* <code>close</code> sets <code>$?</code>.
* If <em>ios</em> is opened by IO.popen, #close sets
* <code>$?</code>.
*
* Calling this method on closed IO object is just ignored since Ruby 2.3.
*/
@ -4914,7 +4910,7 @@ rb_io_closed(VALUE io)
*
* Closes the read end of a duplex I/O stream (i.e., one that contains
* both a read and a write stream, such as a pipe). Will raise an
* <code>IOError</code> if the stream is not duplexed.
* IOError if the stream is not duplexed.
*
* f = IO.popen("/bin/sh","r+")
* f.close_read
@ -4975,7 +4971,7 @@ rb_io_close_read(VALUE io)
*
* Closes the write end of a duplex I/O stream (i.e., one that contains
* both a read and a write stream, such as a pipe). Will raise an
* <code>IOError</code> if the stream is not duplexed.
* IOError if the stream is not duplexed.
*
* f = IO.popen("/bin/sh","r+")
* f.close_write
@ -5028,8 +5024,8 @@ rb_io_close_write(VALUE io)
* ios.sysseek(offset, whence=IO::SEEK_SET) -> integer
*
* Seeks to a given <i>offset</i> in the stream according to the value
* of <i>whence</i> (see <code>IO#seek</code> for values of
* <i>whence</i>). Returns the new offset into the file.
* of <i>whence</i> (see IO#seek for values of <i>whence</i>). Returns
* the new offset into the file.
*
* f = File.new("testfile")
* f.sysseek(-13, IO::SEEK_END) #=> 53
@ -5070,7 +5066,7 @@ rb_io_sysseek(int argc, VALUE *argv, VALUE io)
* Writes the given string to <em>ios</em> using a low-level write.
* Returns the number of bytes written. Do not mix with other methods
* that write to <em>ios</em> or you may get unpredictable results.
* Raises <code>SystemCallError</code> on error.
* Raises SystemCallError on error.
*
* f = File.new("out", "w")
* f.syswrite("ABCDEF") #=> 6
@ -5117,8 +5113,7 @@ rb_io_syswrite(VALUE io, VALUE str)
* The _outbuf_ will contain only the received data after the method call
* even if it is not empty at the beginning.
*
* Raises <code>SystemCallError</code> on error and
* <code>EOFError</code> at end of file.
* Raises SystemCallError on error and EOFError at end of file.
*
* f = File.new("testfile")
* f.sysread(16) #=> "This is line one"
@ -5212,9 +5207,8 @@ pread_internal_call(VALUE arg)
* This bypasses any userspace buffering of the IO layer.
* If the optional <i>outbuf</i> argument is present, it must
* reference a String, which will receive the data.
* Raises <code>SystemCallError</code> on error, <code>EOFError</code>
* at end of file and <code>NotImplementedError</code> if platform does not
* implement the system call.
* Raises SystemCallError on error, EOFError at end of file and
* NotImplementedError if platform does not implement the system call.
*
* File.write("testfile", "This is line one\nThis is line two\n")
* File.open("testfile") do |f|
@ -5283,7 +5277,7 @@ internal_pwrite_func(void *ptr)
* same IO object for reading the file at various locations.
* This bypasses any userspace buffering of the IO layer.
* Returns the number of bytes written.
* Raises <code>SystemCallError</code> on error and <code>NotImplementedError</code>
* Raises SystemCallError on error and NotImplementedError
* if platform does not implement the system call.
*
* File.open("out", "w") do |f|
@ -6795,7 +6789,7 @@ pipe_close(VALUE io)
*
* Runs the specified command as a subprocess; the subprocess's
* standard input and output will be connected to the returned
* <code>IO</code> object.
* IO object.
*
* The PID of the started process can be obtained by IO#pid method.
*
@ -6814,7 +6808,7 @@ pipe_close(VALUE io)
* If <i>cmd</i> is an +Array+ of +String+,
* then it will be used as the subprocess's +argv+ bypassing a shell.
* The array can contain a hash at first for environments and
* a hash at last for options similar to <code>spawn</code>.
* a hash at last for options similar to #spawn.
*
* The default mode for the new file object is ``r'',
* but <i>mode</i> may be set to any of the modes listed in the description for class IO.
@ -6836,15 +6830,13 @@ pipe_close(VALUE io)
* ls_result_with_error = ls_io.read
* }
*
* Raises exceptions which <code>IO.pipe</code> and
* <code>Kernel.spawn</code> raise.
* Raises exceptions which IO.pipe and Kernel.spawn raise.
*
* If a block is given, Ruby will run the command as a child connected
* to Ruby with a pipe. Ruby's end of the pipe will be passed as a
* parameter to the block.
* At the end of block, Ruby closes the pipe and sets <code>$?</code>.
* In this case <code>IO.popen</code> returns
* the value of the block.
* In this case IO.popen returns the value of the block.
*
* If a block is given with a _cmd_ of ``<code>-</code>'',
* the block will be run in two separate processes: once in the parent,
@ -6989,11 +6981,11 @@ rb_open_file(int argc, const VALUE *argv, VALUE io)
* File.open(filename, mode="r" [, opt]) {|file| block } -> obj
* File.open(filename [, mode [, perm]] [, opt]) {|file| block } -> obj
*
* With no associated block, <code>File.open</code> is a synonym for
* With no associated block, File.open is a synonym for
* File.new. If the optional code block is given, it will
* be passed the opened +file+ as an argument and the File object will
* automatically be closed when the block terminates. The value of the block
* will be returned from <code>File.open</code>.
* will be returned from File.open.
*
* If a file is being created, its initial permissions may be set using the
* +perm+ parameter. See File.new for further discussion.
@ -7008,7 +7000,7 @@ rb_open_file(int argc, const VALUE *argv, VALUE io)
* IO.open(fd, mode="r" [, opt]) -> io
* IO.open(fd, mode="r" [, opt]) {|io| block } -> obj
*
* With no associated block, <code>IO.open</code> is a synonym for IO.new. If
* With no associated block, IO.open is a synonym for IO.new. If
* the optional code block is given, it will be passed +io+ as an argument,
* and the IO object will automatically be closed when the block terminates.
* In this instance, IO.open returns the value of the block.
@ -7033,7 +7025,7 @@ rb_io_s_open(int argc, VALUE *argv, VALUE klass)
* IO.sysopen(path, [mode, [perm]]) -> integer
*
* Opens the given path, returning the underlying file descriptor as a
* <code>Integer</code>.
* Integer.
*
* IO.sysopen("testfile") #=> 3
*/
@ -7493,8 +7485,7 @@ rb_io_init_copy(VALUE dest, VALUE io)
* ios.printf(format_string [, obj, ...]) -> nil
*
* Formats and writes to <em>ios</em>, converting parameters under
* control of the format string. See <code>Kernel#sprintf</code>
* for details.
* control of the format string. See Kernel#sprintf for details.
*/
VALUE
@ -7617,11 +7608,10 @@ rb_f_print(int argc, const VALUE *argv)
* call-seq:
* ios.putc(obj) -> obj
*
* If <i>obj</i> is <code>Numeric</code>, write the character whose code is
* the least-significant byte of <i>obj</i>.
* If <i>obj</i> is <code>String</code>, write the first character
* of <i>obj</i> to <em>ios</em>.
* Otherwise, raise <code>TypeError</code>.
* If <i>obj</i> is Numeric, write the character whose code is the
* least-significant byte of <i>obj</i>. If <i>obj</i> is String,
* write the first character of <i>obj</i> to <em>ios</em>. Otherwise,
* raise TypeError.
*
* $stdout.putc "A"
* $stdout.putc 65
@ -8138,8 +8128,8 @@ rb_io_make_open_file(VALUE obj)
* "t" Text file mode
*
* The exclusive access mode ("x") can be used together with "w" to ensure
* the file is created. <code>Errno::EEXIST</code> is raised when it already
* exists. It may not be supported with all kinds of streams (e.g. pipes).
* the file is created. Errno::EEXIST is raised when it already exists.
* It may not be supported with all kinds of streams (e.g. pipes).
*
* When the open mode of original IO is read only, the mode cannot be
* changed to be writable. Similarly, the open mode cannot be changed from
@ -8229,7 +8219,7 @@ rb_io_make_open_file(VALUE obj)
* io.puts "Hello, World!"
*
* Both of above print "Hello, World!" in UTF-16LE to standard error output
* with converting EOL generated by <code>puts</code> to CR.
* with converting EOL generated by #puts to CR.
*/
static VALUE
@ -8307,8 +8297,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
*
* The new File object is buffered mode (or non-sync mode), unless
* +filename+ is a tty.
* See IO#flush, IO#fsync, IO#fdatasync, and <code>IO#sync=</code>
* about sync mode.
* See IO#flush, IO#fsync, IO#fdatasync, and IO#sync= about sync mode.
*
* === Examples
*
@ -8354,7 +8343,7 @@ rb_io_s_new(int argc, VALUE *argv, VALUE klass)
* call-seq:
* IO.for_fd(fd, mode [, opt]) -> io
*
* Synonym for <code>IO.new</code>.
* Synonym for IO.new.
*
*/
@ -8882,7 +8871,7 @@ static VALUE argf_readline(int, VALUE *, VALUE);
* readline(limit) -> string
* readline(sep, limit) -> string
*
* Equivalent to <code>Kernel::gets</code>, except
* Equivalent to Kernel::gets, except
* +readline+ raises +EOFError+ at end of file.
*/
@ -9314,17 +9303,17 @@ advice_arg_check(VALUE advice)
*
* If an error occurs, one of the following exceptions will be raised:
*
* <code>IOError</code>:: The <code>IO</code> stream is closed.
* <code>Errno::EBADF</code>::
* IOError:: The IO stream is closed.
* Errno::EBADF::
* The file descriptor of the current file is invalid.
* <code>Errno::EINVAL</code>:: An invalid value for _advice_ was given.
* <code>Errno::ESPIPE</code>::
* Errno::EINVAL:: An invalid value for _advice_ was given.
* Errno::ESPIPE::
* The file descriptor of the current file refers to a FIFO or
* pipe. (Linux raises <code>Errno::EINVAL</code> in this case).
* <code>TypeError</code>::
* pipe. (Linux raises Errno::EINVAL in this case).
* TypeError::
* Either _advice_ was not a Symbol, or one of the
* other arguments was not an <code>Integer</code>.
* <code>RangeError</code>:: One of the arguments given was too big/small.
* other arguments was not an Integer.
* RangeError:: One of the arguments given was too big/small.
*
* This list is not exhaustive; other Errno:: exceptions are also possible.
*/
@ -9357,29 +9346,28 @@ rb_io_advise(int argc, VALUE *argv, VALUE io)
* IO.select(read_array [, write_array [, error_array [, timeout]]]) -> array or nil
*
* Calls select(2) system call.
* It monitors given arrays of <code>IO</code> objects, waits until one or more
* of <code>IO</code> objects are ready for reading, are ready for writing,
* and have pending exceptions respectively, and returns an array that
* contains arrays of those IO objects. It will return +nil+
* if optional <i>timeout</i> value is given and no <code>IO</code> object
* is ready in <i>timeout</i> seconds.
* It monitors given arrays of IO objects, waits until one or more of
* IO objects are ready for reading, are ready for writing, and have
* pending exceptions respectively, and returns an array that contains
* arrays of those IO objects. It will return +nil+ if optional
* <i>timeout</i> value is given and no IO object is ready in
* <i>timeout</i> seconds.
*
* <code>IO.select</code> peeks the buffer of <code>IO</code> objects for testing readability.
* If the <code>IO</code> buffer is not empty,
* <code>IO.select</code> immediately notifies readability.
* This "peek" only happens for <code>IO</code> objects.
* It does not happen for IO-like objects such as OpenSSL::SSL::SSLSocket.
* IO.select peeks the buffer of IO objects for testing readability.
* If the IO buffer is not empty, IO.select immediately notifies
* readability. This "peek" only happens for IO objects. It does not
* happen for IO-like objects such as OpenSSL::SSL::SSLSocket.
*
* The best way to use <code>IO.select</code> is invoking it
* after nonblocking methods such as <code>read_nonblock</code>, <code>write_nonblock</code>, etc.
* The methods raise an exception which is extended by
* <code>IO::WaitReadable</code> or <code>IO::WaitWritable</code>.
* The modules notify how the caller should wait with <code>IO.select</code>.
* If <code>IO::WaitReadable</code> is raised, the caller should wait for reading.
* If <code>IO::WaitWritable</code> is raised, the caller should wait for writing.
* The best way to use IO.select is invoking it after nonblocking
* methods such as #read_nonblock, #write_nonblock, etc. The methods
* raise an exception which is extended by IO::WaitReadable or
* IO::WaitWritable. The modules notify how the caller should wait
* with IO.select. If IO::WaitReadable is raised, the caller should
* wait for reading. If IO::WaitWritable is raised, the caller should
* wait for writing.
*
* So, blocking read (<code>readpartial</code>) can be emulated using
* <code>read_nonblock</code> and <code>IO.select</code> as follows:
* So, blocking read (#readpartial) can be emulated using
* #read_nonblock and IO.select as follows:
*
* begin
* result = io_like.read_nonblock(maxlen)
@ -9391,57 +9379,57 @@ rb_io_advise(int argc, VALUE *argv, VALUE io)
* retry
* end
*
* Especially, the combination of nonblocking methods and
* <code>IO.select</code> is preferred for <code>IO</code> like
* objects such as <code>OpenSSL::SSL::SSLSocket</code>.
* It has <code>to_io</code> method to return underlying <code>IO</code> object.
* <code>IO.select</code> calls <code>to_io</code> to obtain the file descriptor to wait.
* Especially, the combination of nonblocking methods and IO.select is
* preferred for IO like objects such as OpenSSL::SSL::SSLSocket. It
* has #to_io method to return underlying IO object. IO.select calls
* #to_io to obtain the file descriptor to wait.
*
* This means that readability notified by <code>IO.select</code> doesn't mean
* readability from <code>OpenSSL::SSL::SSLSocket</code> object.
* This means that readability notified by IO.select doesn't mean
* readability from OpenSSL::SSL::SSLSocket object.
*
* The most likely situation is that <code>OpenSSL::SSL::SSLSocket</code> buffers some data.
* <code>IO.select</code> doesn't see the buffer.
* So <code>IO.select</code> can block when <code>OpenSSL::SSL::SSLSocket#readpartial</code> doesn't block.
* The most likely situation is that OpenSSL::SSL::SSLSocket buffers
* some data. IO.select doesn't see the buffer. So IO.select can
* block when OpenSSL::SSL::SSLSocket#readpartial doesn't block.
*
* However, several more complicated situations exist.
*
* SSL is a protocol which is sequence of records.
* The record consists of multiple bytes.
* So, the remote side of SSL sends a partial record,
* <code>IO.select</code> notifies readability but
* <code>OpenSSL::SSL::SSLSocket</code> cannot decrypt a byte and
* <code>OpenSSL::SSL::SSLSocket#readpartial</code> will block.
* So, the remote side of SSL sends a partial record, IO.select
* notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a
* byte and OpenSSL::SSL::SSLSocket#readpartial will block.
*
* Also, the remote side can request SSL renegotiation which forces
* the local SSL engine to write some data.
* This means <code>OpenSSL::SSL::SSLSocket#readpartial</code> may
* invoke <code>write</code> system call and it can block.
* In such a situation, <code>OpenSSL::SSL::SSLSocket#read_nonblock</code>
* raises IO::WaitWritable instead of blocking.
* So, the caller should wait for ready for writability as above example.
* This means OpenSSL::SSL::SSLSocket#readpartial may invoke #write
* system call and it can block.
* In such a situation, OpenSSL::SSL::SSLSocket#read_nonblock raises
* IO::WaitWritable instead of blocking.
* So, the caller should wait for ready for writability as above
* example.
*
* The combination of nonblocking methods and <code>IO.select</code> is
* also useful for streams such as tty, pipe socket socket when
* multiple processes read from a stream.
* The combination of nonblocking methods and IO.select is also useful
* for streams such as tty, pipe socket socket when multiple processes
* read from a stream.
*
* Finally, Linux kernel developers don't guarantee that
* readability of select(2) means readability of following read(2) even
* for a single process.
* See select(2) manual on GNU/Linux system.
*
* Invoking <code>IO.select</code> before <code>IO#readpartial</code> works well as usual.
* However it is not the best way to use <code>IO.select</code>.
* Invoking IO.select before IO#readpartial works well as usual.
* However it is not the best way to use IO.select.
*
* The writability notified by select(2) doesn't show
* how many bytes are writable.
* <code>IO#write</code> method blocks until given whole string is written.
* So, <code>IO#write(two or more bytes)</code> can block after writability is notified by <code>IO.select</code>.
* <code>IO#write_nonblock</code> is required to avoid the blocking.
* IO#write method blocks until given whole string is written.
* So, <code>IO#write(two or more bytes)</code> can block after
* writability is notified by IO.select. IO#write_nonblock is required
* to avoid the blocking.
*
* Blocking write (<code>write</code>) can be emulated using
* <code>write_nonblock</code> and <code>IO.select</code> as follows:
* IO::WaitReadable should also be rescued for SSL renegotiation in <code>OpenSSL::SSL::SSLSocket</code>.
* Blocking write (#write) can be emulated using #write_nonblock and
* IO.select as follows: IO::WaitReadable should also be rescued for
* SSL renegotiation in OpenSSL::SSL::SSLSocket.
*
* while 0 < string.bytesize
* begin
@ -9457,9 +9445,9 @@ rb_io_advise(int argc, VALUE *argv, VALUE io)
* end
*
* === Parameters
* read_array:: an array of <code>IO</code> objects that wait until ready for read
* write_array:: an array of <code>IO</code> objects that wait until ready for write
* error_array:: an array of <code>IO</code> objects that wait for exceptions
* read_array:: an array of IO objects that wait until ready for read
* write_array:: an array of IO objects that wait until ready for write
* error_array:: an array of IO objects that wait for exceptions
* timeout:: a numeric value in second
*
* === Example
@ -9910,9 +9898,9 @@ rb_fcntl(VALUE io, VALUE req, VALUE arg)
* query file-oriented I/O streams. Arguments and results are platform
* dependent. If <i>arg</i> is a number, its value is passed
* directly. If it is a string, it is interpreted as a binary sequence
* of bytes (<code>Array#pack</code> might be a useful way to build this
* string). On Unix platforms, see <code>fcntl(2)</code> for details.
* Not implemented on all platforms.
* of bytes (Array#pack might be a useful way to build this string). On
* Unix platforms, see <code>fcntl(2)</code> for details. Not
* implemented on all platforms.
*/
static VALUE
@ -10166,7 +10154,7 @@ pipe_pair_close(VALUE rw)
* IO.pipe(...) {|read_io, write_io| ... }
*
* Creates a pair of pipe endpoints (connected to each other) and
* returns them as a two-element array of <code>IO</code> objects:
* returns them as a two-element array of IO objects:
* <code>[</code> <i>read_io</i>, <i>write_io</i> <code>]</code>.
*
* If a block is given, the block is called and
@ -10463,8 +10451,8 @@ seek_before_access(VALUE argp)
* 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.
* +length+ bytes (defaulting to the rest of the file). #read ensures
* the file is closed before returning.
*
* If +name+ starts with a pipe character (<code>"|"</code>), a subprocess is
* created in the same way as Kernel#open, and its output is returned.
@ -10529,10 +10517,10 @@ rb_io_s_read(int argc, VALUE *argv, VALUE io)
* call-seq:
* IO.binread(name, [length [, offset]] ) -> string
*
* Opens the file, optionally seeks to the given <i>offset</i>, then returns
* <i>length</i> bytes (defaulting to the rest of the file).
* <code>binread</code> ensures the file is closed before returning.
* The open mode would be "rb:ASCII-8BIT".
* Opens the file, optionally seeks to the given <i>offset</i>, then
* returns <i>length</i> bytes (defaulting to the rest of the file).
* #binread ensures the file is closed before returning. The open mode
* would be <code>"rb:ASCII-8BIT"</code>.
*
* IO.binread("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
* IO.binread("testfile", 20) #=> "This is line one\nThi"
@ -10635,10 +10623,9 @@ io_s_write(int argc, VALUE *argv, VALUE klass, int binary)
* 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.
* <code>write</code> ensures the file is closed before returning.
* If <i>offset</i> is not given in write mode, the file is truncated.
* Otherwise, it is not truncated.
* <i>string</i>, then returns the length written. #write ensures the
* file is closed before returning. If <i>offset</i> is not given in
* write mode, the file is truncated. Otherwise, it is not truncated.
*
* IO.write("testfile", "0123456789", 20) #=> 10
* # File could contain: "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
@ -10684,8 +10671,8 @@ rb_io_s_write(int argc, VALUE *argv, VALUE io)
* IO.binwrite(name, string, [offset] ) -> integer
* IO.binwrite(name, string, [offset], open_args ) -> integer
*
* Same as <code>IO.write</code> except opening the file in binary mode
* and ASCII-8BIT encoding ("wb:ASCII-8BIT").
* Same as IO.write except opening the file in binary mode and
* ASCII-8BIT encoding (<code>"wb:ASCII-8BIT"</code>).
*/
static VALUE
@ -11578,9 +11565,8 @@ copy_stream_finalize(VALUE arg)
*
* IO.copy_stream copies <i>src</i> to <i>dst</i>.
* <i>src</i> and <i>dst</i> is either a filename or an IO-like object.
* IO-like object for <i>src</i> should have <code>readpartial</code> or
* <code>read</code> method.
* IO-like object for <i>dst</i> should have <code>write</code> method.
* IO-like object for <i>src</i> should have #readpartial or #read
* method. IO-like object for <i>dst</i> should have #write method.
* (Specialized mechanisms, such as sendfile system call, may be used
* on appropriate situation.)
*
@ -12103,11 +12089,11 @@ static VALUE argf_getpartial(int argc, VALUE *argv, VALUE argf, VALUE opts,
* The _outbuf_ will contain only the received data after the method call
* even if it is not empty at the beginning.
*
* It raises <code>EOFError</code> on end of ARGF stream.
* It raises EOFError on end of ARGF stream.
* Since ARGF stream is a concatenation of multiple files,
* internally EOF is occur for each file.
* ARGF.readpartial returns empty strings for EOFs except the last one and
* raises <code>EOFError</code> for the last one.
* raises EOFError for the last one.
*
*/
@ -12417,7 +12403,7 @@ argf_each_line(int argc, VALUE *argv, VALUE argf)
}
/*
* This is a deprecated alias for <code>each_line</code>.
* This is a deprecated alias for #each_line.
*/
static VALUE
@ -12464,7 +12450,7 @@ argf_each_byte(VALUE argf)
}
/*
* This is a deprecated alias for <code>each_byte</code>.
* This is a deprecated alias for #each_byte.
*/
static VALUE
@ -12503,7 +12489,7 @@ argf_each_char(VALUE argf)
}
/*
* This is a deprecated alias for <code>each_char</code>.
* This is a deprecated alias for #each_char.
*/
static VALUE
@ -12542,7 +12528,7 @@ argf_each_codepoint(VALUE argf)
}
/*
* This is a deprecated alias for <code>each_codepoint</code>.
* This is a deprecated alias for #each_codepoint.
*/
static VALUE

8
load.c
View file

@ -1120,8 +1120,8 @@ ruby_init_ext(const char *name, void (*init)(void))
* call-seq:
* mod.autoload(module, filename) -> nil
*
* Registers _filename_ to be loaded (using <code>Kernel::require</code>)
* the first time that _module_ (which may be a <code>String</code> or
* Registers _filename_ to be loaded (using Kernel::require)
* the first time that _module_ (which may be a String or
* a symbol) is accessed in the namespace of _mod_.
*
* module A
@ -1167,8 +1167,8 @@ rb_mod_autoload_p(VALUE mod, VALUE sym)
* call-seq:
* autoload(module, filename) -> nil
*
* Registers _filename_ to be loaded (using <code>Kernel::require</code>)
* the first time that _module_ (which may be a <code>String</code> or
* Registers _filename_ to be loaded (using Kernel::require)
* the first time that _module_ (which may be a String or
* a symbol) is accessed.
*
* autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")

153
object.c
View file

@ -167,15 +167,15 @@ rb_eql(VALUE obj1, VALUE obj2)
* obj.equal?(other) -> true or false
* obj.eql?(other) -> true or false
*
* Equality --- At the <code>Object</code> level, <code>==</code> returns
* <code>true</code> only if +obj+ and +other+ are the same object.
* Typically, this method is overridden in descendant classes to provide
* Equality --- At the Object level, #== returns <code>true</code>
* only if +obj+ and +other+ are the same object. Typically, this
* method is overridden in descendant classes to provide
* class-specific meaning.
*
* Unlike <code>==</code>, the <code>equal?</code> method should never be
* overridden by subclasses as it is used to determine object identity
* (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
* same object as <code>b</code>):
* Unlike #==, the #equal? method should never be overridden by
* subclasses as it is used to determine object identity (that is,
* <code>a.equal?(b)</code> if and only if <code>a</code> is the same
* object as <code>b</code>):
*
* obj = "a"
* other = obj.dup
@ -184,14 +184,13 @@ rb_eql(VALUE obj1, VALUE obj2)
* obj.equal? other #=> false
* obj.equal? obj #=> true
*
* The <code>eql?</code> method returns <code>true</code> if +obj+ and
* +other+ refer to the same hash key. This is used by Hash to test members
* for equality. For objects of class <code>Object</code>, <code>eql?</code>
* is synonymous with <code>==</code>. Subclasses normally continue this
* tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
* method, but there are exceptions. <code>Numeric</code> types, for
* example, perform type conversion across <code>==</code>, but not across
* <code>eql?</code>, so:
* The #eql? method returns <code>true</code> if +obj+ and +other+
* refer to the same hash key. This is used by Hash to test members
* for equality. For objects of class Object, #eql? is synonymous
* with #==. Subclasses normally continue this tradition by aliasing
* #eql? to their overridden #== method, but there are exceptions.
* Numeric types, for example, perform type conversion across #==,
* but not across #eql?, so:
*
* 1 == 1.0 #=> true
* 1.eql? 1.0 #=> false
@ -263,9 +262,9 @@ rb_class_real(VALUE cl)
* call-seq:
* obj.class -> class
*
* Returns the class of <i>obj</i>. This method must always be
* called with an explicit receiver, as <code>class</code> is also a
* reserved word in Ruby.
* Returns the class of <i>obj</i>. This method must always be called
* with an explicit receiver, as #class is also a reserved word in
* Ruby.
*
* 1.class #=> Integer
* self.class #=> Object
@ -375,9 +374,9 @@ special_object_p(VALUE obj)
*
* Produces a shallow copy of <i>obj</i>---the instance variables of
* <i>obj</i> are copied, but not the objects they reference.
* <code>clone</code> copies the frozen (unless :freeze keyword argument
* is given with a false value) and tainted state of <i>obj</i>.
* See also the discussion under <code>Object#dup</code>.
* #clone copies the frozen (unless +:freeze+ keyword argument is
* given with a false value) and tainted state of <i>obj</i>. See
* also the discussion under Object#dup.
*
* class Klass
* attr_accessor :str
@ -484,7 +483,7 @@ rb_obj_clone(VALUE obj)
*
* Produces a shallow copy of <i>obj</i>---the instance variables of
* <i>obj</i> are copied, but not the objects they reference.
* <code>dup</code> copies the tainted state of <i>obj</i>.
* #dup copies the tainted state of <i>obj</i>.
*
* This method may have class-specific behavior. If so, that
* behavior will be documented under the #+initialize_copy+ method of
@ -492,11 +491,10 @@ rb_obj_clone(VALUE obj)
*
* === on dup vs clone
*
* In general, <code>clone</code> and <code>dup</code> may have different
* semantics in descendant classes. While <code>clone</code> is used to
* duplicate an object, including its internal state, <code>dup</code>
* typically uses the class of the descendant object to create the new
* instance.
* In general, #clone and #dup may have different semantics in
* descendant classes. While #clone is used to duplicate an object,
* including its internal state, #dup typically uses the class of the
* descendant object to create the new instance.
*
* When using #dup, any modules that the object has been extended with will not
* be copied.
@ -637,10 +635,10 @@ rb_obj_init_dup_clone(VALUE obj, VALUE orig)
* call-seq:
* obj.to_s -> string
*
* Returns a string representing <i>obj</i>. The default
* <code>to_s</code> prints the object's class and an encoding of the
* object id. As a special case, the top-level object that is the
* initial execution context of Ruby programs returns ``main''.
* Returns a string representing <i>obj</i>. The default #to_s prints
* the object's class and an encoding of the object id. As a special
* case, the top-level object that is the initial execution context
* of Ruby programs returns ``main''.
*
*--
* Default implementation of \c #to_s.
@ -732,13 +730,12 @@ inspect_obj(VALUE obj, VALUE str, int recur)
* obj.inspect -> string
*
* Returns a string containing a human-readable representation of <i>obj</i>.
* The default <code>inspect</code> shows the object's class name,
* an encoding of the object id, and a list of the instance variables and
* their values (by calling #inspect on each of them).
* User defined classes should override this method to provide a better
* representation of <i>obj</i>. When overriding this method, it should
* return a string whose encoding is compatible with the default external
* encoding.
* The default #inspect shows the object's class name, an encoding of
* the object id, and a list of the instance variables and their
* values (by calling #inspect on each of them). User defined classes
* should override this method to provide a better representation of
* <i>obj</i>. When overriding this method, it should return a string
* whose encoding is compatible with the default external encoding.
*
* [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
* Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
@ -794,7 +791,7 @@ static VALUE class_search_ancestor(VALUE cl, VALUE c);
* obj.instance_of?(class) -> true or false
*
* Returns <code>true</code> if <i>obj</i> is an instance of the given
* class. See also <code>Object#kind_of?</code>.
* class. See also Object#kind_of?.
*
* class A; end
* class B < A; end
@ -1322,9 +1319,9 @@ rb_obj_infect(VALUE victim, VALUE carrier)
* obj.freeze -> obj
*
* Prevents further modifications to <i>obj</i>. A
* <code>RuntimeError</code> will be raised if modification is attempted.
* RuntimeError will be raised if modification is attempted.
* There is no way to unfreeze a frozen object. See also
* <code>Object#frozen?</code>.
* Object#frozen?.
*
* This method returns self.
*
@ -1496,7 +1493,7 @@ nil_match(VALUE obj1, VALUE obj2)
* Document-class: TrueClass
*
* The global value <code>true</code> is the only instance of class
* <code>TrueClass</code> and represents a logically true value in
* TrueClass and represents a logically true value in
* boolean expressions. The class provides operators allowing
* <code>true</code> to be used in logical expressions.
*/
@ -1573,7 +1570,7 @@ true_xor(VALUE obj, VALUE obj2)
* Document-class: FalseClass
*
* The global value <code>false</code> is the only instance of class
* <code>FalseClass</code> and represents a logically false value in
* FalseClass and represents a logically false value in
* boolean expressions. The class provides operators allowing
* <code>false</code> to participate correctly in logical expressions.
*
@ -1715,16 +1712,16 @@ rb_obj_not_match(VALUE obj1, VALUE obj2)
* Returns 0 if +obj+ and +other+ are the same object
* or <code>obj == other</code>, otherwise nil.
*
* The <code><=></code> is used by various methods to compare objects, for example
* The #<=> is used by various methods to compare objects, for example
* Enumerable#sort, Enumerable#max etc.
*
* Your implementation of <code><=></code> should return one of the following values: -1, 0,
* Your implementation of #<=> should return one of the following values: -1, 0,
* 1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
* 1 means self is bigger than other. Nil means the two values could not be
* compared.
*
* When you define <code><=></code>, you can include Comparable to gain the methods
* <code><=</code>, <code><</code>, <code>==</code>, <code>>=</code>, <code>></code> and <code>between?</code>.
* When you define #<=>, you can include Comparable to gain the
* methods #<=, #<, #==, #>=, #> and #between?.
*/
static VALUE
rb_obj_cmp(VALUE obj1, VALUE obj2)
@ -1738,16 +1735,16 @@ rb_obj_cmp(VALUE obj1, VALUE obj2)
*
* Document-class: Module
*
* A <code>Module</code> is a collection of methods and constants. The
* A Module is a collection of methods and constants. The
* methods in a module may be instance methods or module methods.
* Instance methods appear as methods in a class when the module is
* included, module methods do not. Conversely, module methods may be
* called without creating an encapsulating object, while instance
* methods may not. (See <code>Module#module_function</code>.)
* methods may not. (See Module#module_function.)
*
* In the descriptions that follow, the parameter <i>sym</i> refers
* to a symbol, which is either a quoted string or a
* <code>Symbol</code> (such as <code>:name</code>).
* Symbol (such as <code>:name</code>).
*
* module Mod
* include Math
@ -1986,7 +1983,7 @@ rb_class_s_alloc(VALUE klass)
*
* Creates a new anonymous module. If a block is given, it is passed
* the module object, and the block is evaluated in the context of this
* module like <code>module_eval</code>.
* module like #module_eval.
*
* fred = Module.new do
* def meth1
@ -2031,12 +2028,12 @@ rb_mod_initialize_clone(VALUE clone, VALUE orig)
* Class.new(super_class=Object) { |mod| ... } -> a_class
*
* Creates a new anonymous (unnamed) class with the given superclass
* (or <code>Object</code> if no parameter is given). You can give a
* (or Object if no parameter is given). You can give a
* class a name by assigning the class object to a constant.
*
* If a block is given, it is passed the class object, and the block
* is evaluated in the context of this class like
* <code>class_eval</code>.
* #class_eval.
*
* fred = Class.new do
* def meth1
@ -2170,11 +2167,10 @@ rb_class_allocate_instance(VALUE klass)
* call-seq:
* class.new(args, ...) -> obj
*
* Calls <code>allocate</code> to create a new object of
* <i>class</i>'s class, then invokes that object's
* <code>initialize</code> method, passing it <i>args</i>.
* This is the method that ends up getting called whenever
* an object is constructed using .new.
* Calls #allocate to create a new object of <i>class</i>'s class,
* then invokes that object's #initialize method, passing it
* <i>args</i>. This is the method that ends up getting called
* whenever an object is constructed using <code>.new</code>.
*
*/
@ -2340,7 +2336,7 @@ rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass)
* attr(name, true) -> nil
* attr(name, false) -> nil
*
* The first form is equivalent to <code>attr_reader</code>.
* The first form is equivalent to #attr_reader.
* The second form is equivalent to <code>attr_accessor(name)</code> but deprecated.
* The last form is equivalent to <code>attr_reader(name)</code> but deprecated.
*--
@ -2706,7 +2702,7 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
* Returns the value of the given instance variable, or nil if the
* instance variable is not set. The <code>@</code> part of the
* variable name should be included for regular instance
* variables. Throws a <code>NameError</code> exception if the
* variables. Throws a NameError exception if the
* supplied symbol is not valid as an instance variable name.
* String arguments are converted to symbols.
*
@ -2799,7 +2795,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv)
* mod.class_variable_get(string) -> obj
*
* Returns the value of the given class variable (or throws a
* <code>NameError</code> exception). The <code>@@</code> part of the
* NameError exception). The <code>@@</code> part of the
* variable name should be included for regular class variables.
* String arguments are converted to symbols.
*
@ -3223,15 +3219,15 @@ opts_exception_p(VALUE opts)
* call-seq:
* Integer(arg, base=0, exception: true) -> integer or nil
*
* Converts <i>arg</i> to an <code>Integer</code>.
* Converts <i>arg</i> to an Integer.
* Numeric types are converted directly (with floating point numbers
* being truncated). <i>base</i> (0, or between 2 and 36) is a base for
* integer string representation. If <i>arg</i> is a <code>String</code>,
* integer string representation. If <i>arg</i> is a String,
* when <i>base</i> is omitted or equals zero, radix indicators
* (<code>0</code>, <code>0b</code>, and <code>0x</code>) are honored.
* In any case, strings should be strictly conformed to numeric
* representation. This behavior is different from that of
* <code>String#to_i</code>. Non string values will be converted by first
* String#to_i. Non string values will be converted by first
* trying <code>to_int</code>, then <code>to_i</code>.
*
* Passing <code>nil</code> raises a TypeError, while passing a String that
@ -3585,11 +3581,13 @@ rb_Float(VALUE val)
* call-seq:
* Float(arg, exception: true) -> float or nil
*
* Returns <i>arg</i> converted to a float. Numeric types are converted
* directly, and with exception to string and nil the rest are converted using <i>arg</i>.to_f.
* Converting a <code>string</code> with invalid characters will result in a <code>ArgumentError</code>.
* Converting <code>nil</code> generates a <code>TypeError</code>.
* Exceptions can be suppressed by passing <code>exception: false</code>.
* Returns <i>arg</i> converted to a float. Numeric types are
* converted directly, and with exception to String and
* <code>nil</code> the rest are converted using
* <i>arg</i><code>.to_f</code>. Converting a String with invalid
* characters will result in a ArgumentError. Converting
* <code>nil</code> generates a TypeError. Exceptions can be
* suppressed by passing <code>exception: false</code>.
*
* Float(1) #=> 1.0
* Float("123.456") #=> 123.456
@ -3746,7 +3744,7 @@ rb_String(VALUE val)
* call-seq:
* String(arg) -> string
*
* Returns <i>arg</i> as a <code>String</code>.
* Returns <i>arg</i> as a String.
*
* First tries to call its <code>to_str</code> method, then its <code>to_s</code> method.
*
@ -3789,7 +3787,7 @@ rb_Array(VALUE val)
* returns an Array of length 1 containing +arg+.
*
* If <code>to_ary</code> or <code>to_a</code> returns something other than
* an Array, raises a <code>TypeError</code>.
* an Array, raises a TypeError.
*
* Array(["a", "b"]) #=> ["a", "b"]
* Array(1..5) #=> [1, 2, 3, 4, 5]
@ -3826,8 +3824,8 @@ rb_Hash(VALUE val)
* call-seq:
* Hash(arg) -> hash
*
* Converts <i>arg</i> to a <code>Hash</code> by calling
* <i>arg</i><code>.to_hash</code>. Returns an empty <code>Hash</code> when
* Converts <i>arg</i> to a Hash by calling
* <i>arg</i><code>.to_hash</code>. Returns an empty Hash when
* <i>arg</i> is <tt>nil</tt> or <tt>[]</tt>.
*
* Hash([]) #=> {}
@ -3910,7 +3908,7 @@ rb_obj_dig(int argc, VALUE *argv, VALUE obj, VALUE notfound)
* Document-class: Class
*
* Classes in Ruby are first-class objects---each is an instance of
* class <code>Class</code>.
* class Class.
*
* Typically, you create a new class by using:
*
@ -3919,12 +3917,11 @@ rb_obj_dig(int argc, VALUE *argv, VALUE obj, VALUE notfound)
* end
*
* When a new class is created, an object of type Class is initialized and
* assigned to a global constant (<code>Name</code> in this case).
* assigned to a global constant (Name in this case).
*
* When <code>Name.new</code> is called to create a new object, the
* <code>new</code> method in <code>Class</code> is run by default.
* This can be demonstrated by overriding <code>new</code> in
* <code>Class</code>:
* #new method in Class is run by default.
* This can be demonstrated by overriding #new in Class:
*
* class Class
* alias old_new new