rbs 3.9.4 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.clang-format +75 -0
- data/.clangd +2 -0
- data/.dockerignore +37 -0
- data/.gitattributes +1 -0
- data/.github/dependabot.yml +16 -14
- data/.github/workflows/bundle-update.yml +63 -0
- data/.github/workflows/c-check.yml +66 -0
- data/.github/workflows/changelog.yml +121 -0
- data/.github/workflows/comments.yml +6 -4
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/jruby.yml +74 -0
- data/.github/workflows/release-gems.yml +234 -0
- data/.github/workflows/ruby.yml +86 -32
- data/.github/workflows/rust.yml +186 -0
- data/.github/workflows/truffleruby.yml +54 -0
- data/.github/workflows/typecheck.yml +6 -3
- data/.github/workflows/wasm.yml +55 -0
- data/.github/workflows/windows.yml +10 -4
- data/.gitignore +16 -0
- data/.rubocop.yml +1 -2
- data/CHANGELOG.md +502 -0
- data/Dockerfile.jruby +53 -0
- data/README.md +42 -5
- data/Rakefile +892 -111
- data/Steepfile +11 -0
- data/config.yml +665 -62
- data/core/array.rbs +541 -398
- data/core/basic_object.rbs +9 -8
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +9 -8
- data/core/class.rbs +11 -8
- data/core/comparable.rbs +55 -34
- data/core/complex.rbs +104 -78
- data/core/dir.rbs +61 -49
- data/core/encoding.rbs +12 -15
- data/core/enumerable.rbs +297 -196
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator/product.rbs +5 -5
- data/core/enumerator.rbs +91 -28
- data/core/errno.rbs +11 -2
- data/core/errors.rbs +58 -29
- data/core/exception.rbs +13 -13
- data/core/fiber.rbs +74 -54
- data/core/file.rbs +260 -1151
- data/core/file_constants.rbs +463 -0
- data/core/file_stat.rbs +534 -0
- data/core/file_test.rbs +3 -3
- data/core/float.rbs +257 -116
- data/core/gc.rbs +425 -281
- data/core/hash.rbs +1151 -829
- data/core/integer.rbs +156 -195
- data/core/io/buffer.rbs +53 -42
- data/core/io/wait.rbs +13 -35
- data/core/io.rbs +222 -155
- data/core/kernel.rbs +239 -163
- data/core/marshal.rbs +4 -4
- data/core/match_data.rbs +16 -14
- data/core/math.rbs +107 -66
- data/core/method.rbs +69 -33
- data/core/module.rbs +302 -150
- data/core/nil_class.rbs +7 -6
- data/core/numeric.rbs +77 -63
- data/core/object.rbs +9 -11
- data/core/object_space/weak_key_map.rbs +7 -7
- data/core/object_space.rbs +30 -23
- data/core/pathname.rbs +1312 -0
- data/core/proc.rbs +95 -58
- data/core/process.rbs +222 -202
- data/core/ractor.rbs +364 -518
- data/core/random.rbs +21 -3
- data/core/range.rbs +181 -79
- data/core/rational.rbs +60 -89
- data/core/rbs/ops.rbs +154 -0
- data/core/rbs/unnamed/argf.rbs +63 -56
- data/core/rbs/unnamed/env_class.rbs +19 -14
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +11 -118
- data/core/regexp.rbs +258 -214
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +78 -34
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +6 -70
- data/core/rubygems/requirement.rbs +5 -15
- data/core/rubygems/rubygems.rbs +18 -81
- data/core/rubygems/specification.rbs +8 -0
- data/core/rubygems/version.rbs +2 -163
- data/core/set.rbs +493 -363
- data/core/signal.rbs +26 -16
- data/core/string.rbs +3234 -1285
- data/core/struct.rbs +43 -42
- data/core/symbol.rbs +41 -34
- data/core/thread.rbs +139 -83
- data/core/time.rbs +81 -50
- data/core/trace_point.rbs +41 -35
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +24 -16
- data/core/warning.rbs +7 -7
- data/docs/CONTRIBUTING.md +3 -2
- data/docs/aliases.md +79 -0
- data/docs/collection.md +3 -3
- data/docs/config.md +171 -0
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/inline.md +634 -0
- data/docs/rbs_by_example.md +20 -20
- data/docs/release.md +303 -0
- data/docs/rust.md +96 -0
- data/docs/sigs.md +3 -3
- data/docs/stdlib.md +8 -0
- data/docs/syntax.md +60 -18
- data/docs/type_fingerprint.md +21 -0
- data/docs/wasm_serialization.md +80 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +1870 -0
- data/ext/rbs_extension/ast_translation.h +41 -0
- data/ext/rbs_extension/class_constants.c +189 -0
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +24 -1
- data/ext/rbs_extension/compat.h +10 -0
- data/ext/rbs_extension/extconf.rb +26 -1
- data/ext/rbs_extension/legacy_location.c +299 -0
- data/ext/rbs_extension/legacy_location.h +82 -0
- data/ext/rbs_extension/main.c +639 -23
- data/ext/rbs_extension/rbs_extension.h +6 -21
- data/ext/rbs_extension/rbs_string_bridging.c +9 -0
- data/ext/rbs_extension/rbs_string_bridging.h +24 -0
- data/include/rbs/ast.h +1055 -0
- data/include/rbs/defines.h +104 -0
- data/include/rbs/lexer.h +208 -0
- data/include/rbs/location.h +40 -0
- data/include/rbs/parser.h +187 -0
- data/include/rbs/serialize.h +39 -0
- data/include/rbs/string.h +47 -0
- data/include/rbs/util/rbs_allocator.h +59 -0
- data/include/rbs/util/rbs_assert.h +20 -0
- data/include/rbs/util/rbs_buffer.h +83 -0
- data/include/rbs/util/rbs_constant_pool.h +6 -70
- data/include/rbs/util/rbs_encoding.h +282 -0
- data/include/rbs/util/rbs_unescape.h +24 -0
- data/include/rbs.h +9 -2
- data/lib/rbs/annotate/formatter.rb +3 -13
- data/lib/rbs/annotate/rdoc_annotator.rb +30 -32
- data/lib/rbs/annotate/rdoc_source.rb +1 -1
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +11 -11
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +451 -0
- data/lib/rbs/ast/ruby/comment_block.rb +247 -0
- data/lib/rbs/ast/ruby/declarations.rb +291 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +762 -0
- data/lib/rbs/ast/type_param.rb +25 -5
- data/lib/rbs/buffer.rb +142 -20
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +63 -126
- data/lib/rbs/cli.rb +59 -29
- data/lib/rbs/collection/config/lockfile_generator.rb +28 -3
- data/lib/rbs/collection/sources/git.rb +7 -0
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +129 -70
- data/lib/rbs/definition_builder/method_builder.rb +74 -33
- data/lib/rbs/definition_builder.rb +181 -21
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment/class_entry.rb +81 -0
- data/lib/rbs/environment/module_entry.rb +91 -0
- data/lib/rbs/environment.rb +410 -215
- data/lib/rbs/environment_loader.rb +2 -8
- data/lib/rbs/errors.rb +31 -21
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +568 -0
- data/lib/rbs/location_aux.rb +36 -4
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/namespace.rb +47 -18
- data/lib/rbs/parser_aux.rb +37 -7
- data/lib/rbs/prototype/helpers.rb +24 -0
- data/lib/rbs/prototype/rb.rb +3 -28
- data/lib/rbs/prototype/rbi.rb +196 -45
- data/lib/rbs/prototype/runtime/value_object_generator.rb +0 -1
- data/lib/rbs/prototype/runtime.rb +13 -3
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +120 -44
- data/lib/rbs/rewriter.rb +70 -0
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +7 -4
- data/lib/rbs/test/type_check.rb +25 -3
- data/lib/rbs/type_name.rb +34 -21
- data/lib/rbs/types.rb +135 -81
- data/lib/rbs/unit_test/convertibles.rb +1 -0
- data/lib/rbs/unit_test/type_assertions.rb +47 -11
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/wasm/deserializer.rb +213 -0
- data/lib/rbs/wasm/location.rb +61 -0
- data/lib/rbs/wasm/parser.rb +174 -0
- data/lib/rbs/wasm/runtime.rb +211 -0
- data/lib/rbs/wasm/serialization_schema.rb +111 -0
- data/lib/rbs.rb +25 -2
- data/lib/rbs_jars.rb +39 -0
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +8 -3
- data/rbs.gemspec +34 -6
- data/schema/function.json +12 -1
- data/schema/typeParam.json +17 -1
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +13 -10
- data/sig/ast/ruby/annotations.rbs +470 -0
- data/sig/ast/ruby/comment_block.rbs +127 -0
- data/sig/ast/ruby/declarations.rbs +158 -0
- data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
- data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
- data/sig/ast/ruby/members.rbs +198 -0
- data/sig/buffer.rbs +81 -5
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +12 -8
- data/sig/cli.rbs +18 -18
- data/sig/collection/config/lockfile_generator.rbs +2 -0
- data/sig/definition.rbs +6 -0
- data/sig/definition_builder.rbs +3 -1
- data/sig/environment/class_entry.rbs +56 -0
- data/sig/environment/module_entry.rbs +65 -0
- data/sig/environment.rbs +94 -87
- data/sig/errors.rbs +26 -20
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +126 -0
- data/sig/location.rbs +32 -7
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -2
- data/sig/method_builder.rbs +9 -4
- data/sig/namespace.rbs +20 -5
- data/sig/parser.rbs +79 -15
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/prototype/rbi.rbs +33 -4
- data/sig/resolver/type_name_resolver.rbs +36 -10
- data/sig/rewriter.rbs +45 -0
- data/sig/source.rbs +48 -0
- data/sig/type_param.rbs +13 -8
- data/sig/typename.rbs +15 -5
- data/sig/types.rbs +21 -9
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +17 -2
- data/sig/wasm/deserializer.rbs +66 -0
- data/sig/wasm/serialization_schema.rbs +13 -0
- data/src/ast.c +1644 -0
- data/src/lexer.c +3223 -0
- data/src/lexer.re +187 -0
- data/src/lexstate.c +222 -0
- data/src/location.c +31 -0
- data/src/parser.c +4318 -0
- data/src/serialize.c +965 -0
- data/src/string.c +41 -0
- data/src/util/rbs_allocator.c +171 -0
- data/src/util/rbs_assert.c +19 -0
- data/src/util/rbs_buffer.c +54 -0
- data/src/util/rbs_constant_pool.c +18 -92
- data/src/util/rbs_encoding.c +21454 -0
- data/src/util/rbs_unescape.c +167 -0
- data/stdlib/abbrev/0/array.rbs +1 -1
- data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +7 -4
- data/stdlib/csv/0/csv.rbs +5 -5
- data/stdlib/date/0/date.rbs +92 -79
- data/stdlib/date/0/date_time.rbs +25 -24
- data/stdlib/delegate/0/delegator.rbs +11 -7
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/digest/0/digest.rbs +117 -1
- data/stdlib/erb/0/erb.rbs +754 -353
- data/stdlib/etc/0/etc.rbs +73 -54
- data/stdlib/fileutils/0/fileutils.rbs +179 -160
- data/stdlib/forwardable/0/forwardable.rbs +13 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/ipaddr/0/ipaddr.rbs +0 -5
- data/stdlib/json/0/json.rbs +232 -185
- data/stdlib/monitor/0/monitor.rbs +9 -9
- data/stdlib/net-http/0/net-http.rbs +162 -134
- data/stdlib/objspace/0/objspace.rbs +17 -34
- data/stdlib/open-uri/0/open-uri.rbs +48 -8
- data/stdlib/open3/0/open3.rbs +469 -10
- data/stdlib/openssl/0/openssl.rbs +521 -397
- data/stdlib/optparse/0/optparse.rbs +26 -17
- data/stdlib/pathname/0/pathname.rbs +11 -1381
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +65 -12
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +4 -3
- data/stdlib/rdoc/0/comment.rbs +2 -0
- data/stdlib/rdoc/0/options.rbs +76 -0
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/rdoc.rbs +7 -5
- data/stdlib/rdoc/0/store.rbs +2 -2
- data/stdlib/resolv/0/resolv.rbs +26 -69
- data/stdlib/ripper/0/ripper.rbs +25 -19
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +7 -20
- data/stdlib/shellwords/0/shellwords.rbs +3 -3
- data/stdlib/singleton/0/singleton.rbs +6 -0
- data/stdlib/socket/0/addrinfo.rbs +9 -9
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +23 -10
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +11 -3
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +1211 -96
- data/stdlib/strscan/0/string_scanner.rbs +101 -80
- data/stdlib/tempfile/0/manifest.yaml +3 -0
- data/stdlib/tempfile/0/tempfile.rbs +25 -21
- data/stdlib/time/0/time.rbs +8 -6
- data/stdlib/timeout/0/timeout.rbs +58 -7
- data/stdlib/tsort/0/cyclic.rbs +4 -1
- data/stdlib/tsort/0/interfaces.rbs +8 -8
- data/stdlib/tsort/0/tsort.rbs +16 -15
- data/stdlib/uri/0/common.rbs +42 -20
- data/stdlib/uri/0/file.rbs +3 -3
- data/stdlib/uri/0/generic.rbs +21 -18
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_file.rbs +1 -1
- data/stdlib/zlib/0/gzip_reader.rbs +8 -8
- data/stdlib/zlib/0/gzip_writer.rbs +16 -13
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- data/wasm/README.md +109 -0
- data/wasm/rbs_wasm.c +479 -0
- metadata +133 -19
- data/ext/rbs_extension/lexer.c +0 -2728
- data/ext/rbs_extension/lexer.h +0 -179
- data/ext/rbs_extension/lexer.re +0 -147
- data/ext/rbs_extension/lexstate.c +0 -175
- data/ext/rbs_extension/location.c +0 -325
- data/ext/rbs_extension/location.h +0 -85
- data/ext/rbs_extension/parser.c +0 -2982
- data/ext/rbs_extension/parser.h +0 -18
- data/ext/rbs_extension/parserstate.c +0 -411
- data/ext/rbs_extension/parserstate.h +0 -163
- data/ext/rbs_extension/unescape.c +0 -32
- data/include/rbs/ruby_objs.h +0 -72
- data/src/constants.c +0 -153
- data/src/ruby_objs.c +0 -799
data/core/io.rbs
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
# classes in the Ruby standard library are also subclasses of IO; these include
|
|
8
8
|
# TCPSocket and UDPSocket.
|
|
9
9
|
#
|
|
10
|
-
# The global constant ARGF (also accessible as
|
|
11
|
-
# that allows access to all file paths found in ARGV (or found in
|
|
12
|
-
# is empty). ARGF is not itself a subclass of IO.
|
|
10
|
+
# The global constant ARGF (also accessible as <code>$<</code>) provides an
|
|
11
|
+
# IO-like stream that allows access to all file paths found in ARGV (or found in
|
|
12
|
+
# STDIN if ARGV is empty). ARGF is not itself a subclass of IO.
|
|
13
13
|
#
|
|
14
14
|
# Class StringIO provides an IO-like stream that handles a String. StringIO is
|
|
15
15
|
# not itself a subclass of IO.
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
# from the position mentioned above); see [Line
|
|
47
47
|
# Number](rdoc-ref:IO@Line+Number).
|
|
48
48
|
#
|
|
49
|
-
# ## Extension
|
|
49
|
+
# ## Extension <code>io/console</code>
|
|
50
50
|
#
|
|
51
|
-
# Extension
|
|
52
|
-
# console; requiring it adds numerous methods to class IO.
|
|
51
|
+
# Extension <code>io/console</code> provides numerous methods for interacting
|
|
52
|
+
# with the console; requiring it adds numerous methods to class IO.
|
|
53
53
|
#
|
|
54
54
|
# ## Example Files
|
|
55
55
|
#
|
|
@@ -86,23 +86,23 @@
|
|
|
86
86
|
# A number of IO methods accept optional keyword arguments that determine how a
|
|
87
87
|
# new stream is to be opened:
|
|
88
88
|
#
|
|
89
|
-
# *
|
|
90
|
-
# *
|
|
91
|
-
# bitwise-ORed.
|
|
92
|
-
# *
|
|
93
|
-
# *
|
|
94
|
-
# for the default internal encoding. If the
|
|
95
|
-
# occurs.
|
|
96
|
-
# *
|
|
97
|
-
#
|
|
98
|
-
# *
|
|
99
|
-
# otherwise.
|
|
100
|
-
# *
|
|
101
|
-
# otherwise.
|
|
102
|
-
# *
|
|
103
|
-
# the stream closes; otherwise it remains open.
|
|
104
|
-
# *
|
|
105
|
-
# available as #path method.
|
|
89
|
+
# * <code>:mode</code>: Stream mode.
|
|
90
|
+
# * <code>:flags</code>: Integer file open flags; If `mode` is also given, the
|
|
91
|
+
# two are bitwise-ORed.
|
|
92
|
+
# * <code>:external_encoding</code>: External encoding for the stream.
|
|
93
|
+
# * <code>:internal_encoding</code>: Internal encoding for the stream.
|
|
94
|
+
# <code>'-'</code> is a synonym for the default internal encoding. If the
|
|
95
|
+
# value is `nil` no conversion occurs.
|
|
96
|
+
# * <code>:encoding</code>: Specifies external and internal encodings as
|
|
97
|
+
# <code>'extern:intern'</code>.
|
|
98
|
+
# * <code>:textmode</code>: If a truthy value, specifies the mode as
|
|
99
|
+
# text-only, binary otherwise.
|
|
100
|
+
# * <code>:binmode</code>: If a truthy value, specifies the mode as binary,
|
|
101
|
+
# text-only otherwise.
|
|
102
|
+
# * <code>:autoclose</code>: If a truthy value, specifies that the `fd` will
|
|
103
|
+
# close when the stream closes; otherwise it remains open.
|
|
104
|
+
# * <code>:path:</code> If a string value is provided, it is used in #inspect
|
|
105
|
+
# and is available as #path method.
|
|
106
106
|
#
|
|
107
107
|
# Also available are the options offered in String#encode, which may control
|
|
108
108
|
# conversion between external and internal encoding.
|
|
@@ -129,8 +129,8 @@
|
|
|
129
129
|
#
|
|
130
130
|
# The relevant methods:
|
|
131
131
|
#
|
|
132
|
-
# * IO#tell (aliased as
|
|
133
|
-
# the stream.
|
|
132
|
+
# * IO#tell (aliased as <code>#pos</code>): Returns the current position (in
|
|
133
|
+
# bytes) in the stream.
|
|
134
134
|
# * IO#pos=: Sets the position of the stream to a given integer `new_position`
|
|
135
135
|
# (in bytes).
|
|
136
136
|
# * IO#seek: Sets the position of the stream to a given integer `offset` (in
|
|
@@ -158,8 +158,8 @@
|
|
|
158
158
|
#
|
|
159
159
|
# You can query whether a stream is positioned at its end:
|
|
160
160
|
#
|
|
161
|
-
# * IO#eof? (also aliased as
|
|
162
|
-
# end-of-stream.
|
|
161
|
+
# * IO#eof? (also aliased as <code>#eof</code>): Returns whether the stream is
|
|
162
|
+
# at end-of-stream.
|
|
163
163
|
#
|
|
164
164
|
# You can reposition to end-of-stream by using method IO#seek:
|
|
165
165
|
#
|
|
@@ -225,8 +225,8 @@
|
|
|
225
225
|
# separator*: the string that determines what is considered a line; it is
|
|
226
226
|
# sometimes called the *input record separator*.
|
|
227
227
|
#
|
|
228
|
-
# The default line separator is taken from global variable
|
|
229
|
-
# value is
|
|
228
|
+
# The default line separator is taken from global variable <code>$/</code>,
|
|
229
|
+
# whose initial value is <code>"\n"</code>.
|
|
230
230
|
#
|
|
231
231
|
# Generally, the line to be read next is all data from the current
|
|
232
232
|
# [position](rdoc-ref:IO@Position) to the next line separator (but see [Special
|
|
@@ -250,7 +250,7 @@
|
|
|
250
250
|
# f.gets # => "e\n"
|
|
251
251
|
# f.close
|
|
252
252
|
#
|
|
253
|
-
# Or by setting global variable
|
|
253
|
+
# Or by setting global variable <code>$/</code>:
|
|
254
254
|
#
|
|
255
255
|
# f = File.new('t.txt')
|
|
256
256
|
# $/ = 'l'
|
|
@@ -270,8 +270,8 @@
|
|
|
270
270
|
# f.gets(nil) # => "First line\nSecond line\n\nFourth line\nFifth line\n"
|
|
271
271
|
# f.close
|
|
272
272
|
#
|
|
273
|
-
# *
|
|
274
|
-
# being separated by two consecutive line separators):
|
|
273
|
+
# * <code>''</code> (the empty string): The next "paragraph" is to be read
|
|
274
|
+
# (paragraphs being separated by two consecutive line separators):
|
|
275
275
|
#
|
|
276
276
|
# f = File.new('t.txt')
|
|
277
277
|
# f.gets('') # => "First line\nSecond line\n\n"
|
|
@@ -285,8 +285,8 @@
|
|
|
285
285
|
# multi-byte character will not be split, and so a returned line may be slightly
|
|
286
286
|
# longer than the limit).
|
|
287
287
|
#
|
|
288
|
-
# The default limit value is
|
|
289
|
-
# no limit.
|
|
288
|
+
# The default limit value is <code>-1</code>; any negative limit value means
|
|
289
|
+
# that there is no limit.
|
|
290
290
|
#
|
|
291
291
|
# If there is no limit, the line is determined only by `sep`.
|
|
292
292
|
#
|
|
@@ -385,10 +385,10 @@
|
|
|
385
385
|
# f.lineno # => 1001
|
|
386
386
|
# f.close
|
|
387
387
|
#
|
|
388
|
-
# Associated with the line number is the global variable
|
|
388
|
+
# Associated with the line number is the global variable <code>$.</code>:
|
|
389
389
|
#
|
|
390
|
-
# * When a stream is opened,
|
|
391
|
-
# previous activity in the process:
|
|
390
|
+
# * When a stream is opened, <code>$.</code> is not set; its value is left
|
|
391
|
+
# over from previous activity in the process:
|
|
392
392
|
#
|
|
393
393
|
# $. = 41
|
|
394
394
|
# f = File.new('t.txt')
|
|
@@ -396,7 +396,8 @@
|
|
|
396
396
|
# # => 41
|
|
397
397
|
# f.close
|
|
398
398
|
#
|
|
399
|
-
# * When a stream is read,
|
|
399
|
+
# * When a stream is read, <code>$.</code> is set to the line number for that
|
|
400
|
+
# stream:
|
|
400
401
|
#
|
|
401
402
|
# f0 = File.new('t.txt')
|
|
402
403
|
# f1 = File.new('t.dat')
|
|
@@ -407,7 +408,7 @@
|
|
|
407
408
|
# f0.close
|
|
408
409
|
# f1.close
|
|
409
410
|
#
|
|
410
|
-
# * Methods IO#rewind and IO#seek do not affect
|
|
411
|
+
# * Methods IO#rewind and IO#seek do not affect <code>$.</code>:
|
|
411
412
|
#
|
|
412
413
|
# f = File.new('t.txt')
|
|
413
414
|
# f.readlines # => ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"]
|
|
@@ -652,15 +653,17 @@ class IO < Object
|
|
|
652
653
|
#
|
|
653
654
|
# Argument `advice` is one of the following symbols:
|
|
654
655
|
#
|
|
655
|
-
# *
|
|
656
|
-
# for the specified data. If no advice is given for an open
|
|
657
|
-
# the default assumption.
|
|
658
|
-
# *
|
|
659
|
-
# sequentially (with lower offsets read before higher ones).
|
|
660
|
-
# *
|
|
661
|
-
# *
|
|
662
|
-
# *
|
|
663
|
-
#
|
|
656
|
+
# * <code>:normal</code>: The application has no advice to give about its
|
|
657
|
+
# access pattern for the specified data. If no advice is given for an open
|
|
658
|
+
# file, this is the default assumption.
|
|
659
|
+
# * <code>:sequential</code>: The application expects to access the specified
|
|
660
|
+
# data sequentially (with lower offsets read before higher ones).
|
|
661
|
+
# * <code>:random</code>: The specified data will be accessed in random order.
|
|
662
|
+
# * <code>:noreuse</code>: The specified data will be accessed only once.
|
|
663
|
+
# * <code>:willneed</code>: The specified data will be accessed in the near
|
|
664
|
+
# future.
|
|
665
|
+
# * <code>:dontneed</code>: The specified data will not be accessed in the
|
|
666
|
+
# near future.
|
|
664
667
|
#
|
|
665
668
|
# Not implemented on all platforms.
|
|
666
669
|
#
|
|
@@ -724,8 +727,8 @@ class IO < Object
|
|
|
724
727
|
# If the stream is open for writing, flushes any buffered writes to the
|
|
725
728
|
# operating system before closing.
|
|
726
729
|
#
|
|
727
|
-
# If the stream was opened by IO.popen, sets global variable
|
|
728
|
-
# status).
|
|
730
|
+
# If the stream was opened by IO.popen, sets global variable <code>$?</code>
|
|
731
|
+
# (child exit status).
|
|
729
732
|
#
|
|
730
733
|
# It is not an error to close an IO object that has already been closed. It just
|
|
731
734
|
# returns nil.
|
|
@@ -790,7 +793,7 @@ class IO < Object
|
|
|
790
793
|
# and Closed Streams](rdoc-ref:IO@Open+and+Closed+Streams).
|
|
791
794
|
#
|
|
792
795
|
# If the stream was opened by IO.popen and is also closed for writing, sets
|
|
793
|
-
# global variable
|
|
796
|
+
# global variable <code>$?</code> (child exit status).
|
|
794
797
|
#
|
|
795
798
|
# Example:
|
|
796
799
|
#
|
|
@@ -824,7 +827,7 @@ class IO < Object
|
|
|
824
827
|
# Flushes any buffered writes to the operating system before closing.
|
|
825
828
|
#
|
|
826
829
|
# If the stream was opened by IO.popen and is also closed for reading, sets
|
|
827
|
-
# global variable
|
|
830
|
+
# global variable <code>$?</code> (child exit status).
|
|
828
831
|
#
|
|
829
832
|
# IO.popen('ruby', 'r+') do |pipe|
|
|
830
833
|
# puts pipe.closed?
|
|
@@ -990,8 +993,8 @@ class IO < Object
|
|
|
990
993
|
# - fdatasync -> 0
|
|
991
994
|
# -->
|
|
992
995
|
# Immediately writes to disk all data buffered in the stream, via the operating
|
|
993
|
-
# system's:
|
|
994
|
-
# supported; otherwise raises an exception.
|
|
996
|
+
# system's: <code>fdatasync(2)</code>, if supported, otherwise via
|
|
997
|
+
# <code>fsync(2)</code>, if supported; otherwise raises an exception.
|
|
995
998
|
#
|
|
996
999
|
def fdatasync: () -> Integer?
|
|
997
1000
|
|
|
@@ -1026,7 +1029,7 @@ class IO < Object
|
|
|
1026
1029
|
# - fsync -> 0
|
|
1027
1030
|
# -->
|
|
1028
1031
|
# Immediately writes to disk all data buffered in the stream, via the operating
|
|
1029
|
-
# system's
|
|
1032
|
+
# system's <code>fsync(2)</code>.
|
|
1030
1033
|
#
|
|
1031
1034
|
# Note this difference:
|
|
1032
1035
|
#
|
|
@@ -1036,7 +1039,8 @@ class IO < Object
|
|
|
1036
1039
|
# * IO#fsync: Ensures both that data is flushed from internal buffers, and
|
|
1037
1040
|
# that data is written to disk.
|
|
1038
1041
|
#
|
|
1039
|
-
# Raises an exception if the operating system does not support
|
|
1042
|
+
# Raises an exception if the operating system does not support
|
|
1043
|
+
# <code>fsync(2)</code>.
|
|
1040
1044
|
#
|
|
1041
1045
|
def fsync: () -> Integer?
|
|
1042
1046
|
|
|
@@ -1082,11 +1086,11 @@ class IO < Object
|
|
|
1082
1086
|
# - gets(limit, chomp: false) -> string or nil
|
|
1083
1087
|
# - gets(sep, limit, chomp: false) -> string or nil
|
|
1084
1088
|
# -->
|
|
1085
|
-
# Reads and returns a line from the stream; assigns the return value to
|
|
1086
|
-
# See [Line IO](rdoc-ref:IO@Line+IO).
|
|
1089
|
+
# Reads and returns a line from the stream; assigns the return value to
|
|
1090
|
+
# <code>$_</code>. See [Line IO](rdoc-ref:IO@Line+IO).
|
|
1087
1091
|
#
|
|
1088
1092
|
# With no arguments given, returns the next line as determined by line separator
|
|
1089
|
-
#
|
|
1093
|
+
# <code>$/</code>, or `nil` if none:
|
|
1090
1094
|
#
|
|
1091
1095
|
# f = File.open('t.txt')
|
|
1092
1096
|
# f.gets # => "First line\n"
|
|
@@ -1226,6 +1230,24 @@ class IO < Object
|
|
|
1226
1230
|
#
|
|
1227
1231
|
def ioctl: (Integer integer_cmd, String | Integer argument) -> Integer
|
|
1228
1232
|
|
|
1233
|
+
# <!--
|
|
1234
|
+
# rdoc-file=ext/etc/etc.c
|
|
1235
|
+
# - pathconf(name) -> Integer
|
|
1236
|
+
# -->
|
|
1237
|
+
# Returns pathname configuration variable using fpathconf().
|
|
1238
|
+
#
|
|
1239
|
+
# *name* should be a constant under `Etc` which begins with `PC_`.
|
|
1240
|
+
#
|
|
1241
|
+
# The return value is an integer or nil. nil means indefinite limit.
|
|
1242
|
+
# (fpathconf() returns -1 but errno is not set.)
|
|
1243
|
+
#
|
|
1244
|
+
# require 'etc'
|
|
1245
|
+
# IO.pipe {|r, w|
|
|
1246
|
+
# p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096
|
|
1247
|
+
# }
|
|
1248
|
+
#
|
|
1249
|
+
def pathconf: (Integer name) -> Integer?
|
|
1250
|
+
|
|
1229
1251
|
# <!--
|
|
1230
1252
|
# rdoc-file=io.c
|
|
1231
1253
|
# - isatty -> true or false
|
|
@@ -1316,15 +1338,15 @@ class IO < Object
|
|
|
1316
1338
|
# - print(*objects) -> nil
|
|
1317
1339
|
# -->
|
|
1318
1340
|
# Writes the given objects to the stream; returns `nil`. Appends the output
|
|
1319
|
-
# record separator
|
|
1320
|
-
# [Line IO](rdoc-ref:IO@Line+IO).
|
|
1341
|
+
# record separator <code>$OUTPUT_RECORD_SEPARATOR</code> (<code>$\</code>), if
|
|
1342
|
+
# it is not `nil`. See [Line IO](rdoc-ref:IO@Line+IO).
|
|
1321
1343
|
#
|
|
1322
1344
|
# With argument `objects` given, for each object:
|
|
1323
1345
|
#
|
|
1324
1346
|
# * Converts via its method `to_s` if not a string.
|
|
1325
1347
|
# * Writes to the stream.
|
|
1326
1348
|
# * If not the last object, writes the output field separator
|
|
1327
|
-
#
|
|
1349
|
+
# <code>$OUTPUT_FIELD_SEPARATOR</code> (<code>$,</code>) if it is not `nil`.
|
|
1328
1350
|
#
|
|
1329
1351
|
# With default separators:
|
|
1330
1352
|
#
|
|
@@ -1356,8 +1378,8 @@ class IO < Object
|
|
|
1356
1378
|
#
|
|
1357
1379
|
# "0,0.0,0/1,0+0i,zero,zero\n"
|
|
1358
1380
|
#
|
|
1359
|
-
# With no argument given, writes the content of
|
|
1360
|
-
# recent user input):
|
|
1381
|
+
# With no argument given, writes the content of <code>$_</code> (which is
|
|
1382
|
+
# usually the most recent user input):
|
|
1361
1383
|
#
|
|
1362
1384
|
# f = File.open('t.tmp', 'w+')
|
|
1363
1385
|
# gets # Sets $_ to the most recent user input.
|
|
@@ -1373,7 +1395,7 @@ class IO < Object
|
|
|
1373
1395
|
# Formats and writes `objects` to the stream.
|
|
1374
1396
|
#
|
|
1375
1397
|
# For details on `format_string`, see [Format
|
|
1376
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1398
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1377
1399
|
#
|
|
1378
1400
|
def printf: (String format_string, *untyped objects) -> nil
|
|
1379
1401
|
|
|
@@ -1395,7 +1417,8 @@ class IO < Object
|
|
|
1395
1417
|
#
|
|
1396
1418
|
# AA
|
|
1397
1419
|
#
|
|
1398
|
-
def putc: (
|
|
1420
|
+
def putc: (real) -> real
|
|
1421
|
+
| (String) -> String
|
|
1399
1422
|
|
|
1400
1423
|
# <!--
|
|
1401
1424
|
# rdoc-file=io.c
|
|
@@ -1406,13 +1429,13 @@ class IO < Object
|
|
|
1406
1429
|
# newline sequence. If called without arguments, writes a newline. See [Line
|
|
1407
1430
|
# IO](rdoc-ref:IO@Line+IO).
|
|
1408
1431
|
#
|
|
1409
|
-
# Note that each added newline is the character
|
|
1410
|
-
# record separator (<tt
|
|
1432
|
+
# Note that each added newline is the character <code>"\n"<//tt>, not the output
|
|
1433
|
+
# record separator (<tt>$\</code>).
|
|
1411
1434
|
#
|
|
1412
1435
|
# Treatment for each object:
|
|
1413
1436
|
#
|
|
1414
1437
|
# * String: writes the string.
|
|
1415
|
-
# * Neither string nor array: writes
|
|
1438
|
+
# * Neither string nor array: writes <code>object.to_s</code>.
|
|
1416
1439
|
# * Array: writes each element of the array; arrays may be nested.
|
|
1417
1440
|
#
|
|
1418
1441
|
# To keep these examples brief, we define this helper method:
|
|
@@ -1443,6 +1466,61 @@ class IO < Object
|
|
|
1443
1466
|
#
|
|
1444
1467
|
def puts: (*untyped objects) -> nil
|
|
1445
1468
|
|
|
1469
|
+
# <!--
|
|
1470
|
+
# rdoc-file=io.c
|
|
1471
|
+
# - pread(maxlen, offset) -> string
|
|
1472
|
+
# - pread(maxlen, offset, out_string) -> string
|
|
1473
|
+
# -->
|
|
1474
|
+
# Behaves like IO#readpartial, except that it:
|
|
1475
|
+
#
|
|
1476
|
+
# * Reads at the given `offset` (in bytes).
|
|
1477
|
+
# * Disregards, and does not modify, the stream's position (see
|
|
1478
|
+
# [Position](rdoc-ref:IO@Position)).
|
|
1479
|
+
# * Bypasses any user space buffering in the stream.
|
|
1480
|
+
#
|
|
1481
|
+
# Because this method does not disturb the stream's state (its position, in
|
|
1482
|
+
# particular), `pread` allows multiple threads and processes to use the same IO
|
|
1483
|
+
# object for reading at various offsets.
|
|
1484
|
+
#
|
|
1485
|
+
# f = File.open('t.txt')
|
|
1486
|
+
# f.read # => "First line\nSecond line\n\nFourth line\nFifth line\n"
|
|
1487
|
+
# f.pos # => 52
|
|
1488
|
+
# # Read 12 bytes at offset 0.
|
|
1489
|
+
# f.pread(12, 0) # => "First line\n"
|
|
1490
|
+
# # Read 9 bytes at offset 8.
|
|
1491
|
+
# f.pread(9, 8) # => "ne\nSecon"
|
|
1492
|
+
# f.close
|
|
1493
|
+
#
|
|
1494
|
+
# Not available on some platforms.
|
|
1495
|
+
#
|
|
1496
|
+
def pread: (int maxlen, int offset, ?string? out_string) -> String
|
|
1497
|
+
|
|
1498
|
+
# <!--
|
|
1499
|
+
# rdoc-file=io.c
|
|
1500
|
+
# - pwrite(object, offset) -> integer
|
|
1501
|
+
# -->
|
|
1502
|
+
# Behaves like IO#write, except that it:
|
|
1503
|
+
#
|
|
1504
|
+
# * Writes at the given `offset` (in bytes).
|
|
1505
|
+
# * Disregards, and does not modify, the stream's position (see
|
|
1506
|
+
# [Position](rdoc-ref:IO@Position)).
|
|
1507
|
+
# * Bypasses any user space buffering in the stream.
|
|
1508
|
+
#
|
|
1509
|
+
# Because this method does not disturb the stream's state (its position, in
|
|
1510
|
+
# particular), `pwrite` allows multiple threads and processes to use the same IO
|
|
1511
|
+
# object for writing at various offsets.
|
|
1512
|
+
#
|
|
1513
|
+
# f = File.open('t.tmp', 'w+')
|
|
1514
|
+
# # Write 6 bytes at offset 3.
|
|
1515
|
+
# f.pwrite('ABCDEF', 3) # => 6
|
|
1516
|
+
# f.rewind
|
|
1517
|
+
# f.read # => "\u0000\u0000\u0000ABCDEF"
|
|
1518
|
+
# f.close
|
|
1519
|
+
#
|
|
1520
|
+
# Not available on some platforms.
|
|
1521
|
+
#
|
|
1522
|
+
def pwrite: (_ToS object, int offset) -> Integer
|
|
1523
|
+
|
|
1446
1524
|
# <!--
|
|
1447
1525
|
# rdoc-file=io.c
|
|
1448
1526
|
# - read(maxlen = nil, out_string = nil) -> new_string, out_string, or nil
|
|
@@ -1464,7 +1542,7 @@ class IO < Object
|
|
|
1464
1542
|
# * `out_string` given: encoding of `out_string` not modified.
|
|
1465
1543
|
# * `out_string` not given: ASCII-8BIT is used.
|
|
1466
1544
|
#
|
|
1467
|
-
#
|
|
1545
|
+
# <strong>Without Argument `out_string`</strong>
|
|
1468
1546
|
#
|
|
1469
1547
|
# When argument `out_string` is omitted, the returned value is a new string:
|
|
1470
1548
|
#
|
|
@@ -1479,7 +1557,7 @@ class IO < Object
|
|
|
1479
1557
|
#
|
|
1480
1558
|
# If `maxlen` is zero, returns an empty string.
|
|
1481
1559
|
#
|
|
1482
|
-
#
|
|
1560
|
+
# <strong> With Argument `out_string`</strong>
|
|
1483
1561
|
#
|
|
1484
1562
|
# When argument `out_string` is given, the returned value is `out_string`, whose
|
|
1485
1563
|
# content is replaced:
|
|
@@ -1512,8 +1590,8 @@ class IO < Object
|
|
|
1512
1590
|
#
|
|
1513
1591
|
# Related: IO#write.
|
|
1514
1592
|
#
|
|
1515
|
-
def read: (?nil, ?string outbuf) -> String
|
|
1516
|
-
| (int? length, ?string outbuf) -> String?
|
|
1593
|
+
def read: (?nil, ?string? outbuf) -> String
|
|
1594
|
+
| (int? length, ?string? outbuf) -> String?
|
|
1517
1595
|
|
|
1518
1596
|
# <!--
|
|
1519
1597
|
# rdoc-file=io.rb
|
|
@@ -1565,11 +1643,11 @@ class IO < Object
|
|
|
1565
1643
|
#
|
|
1566
1644
|
# By specifying a keyword argument *exception* to `false`, you can indicate that
|
|
1567
1645
|
# read_nonblock should not raise an IO::WaitReadable exception, but return the
|
|
1568
|
-
# symbol
|
|
1569
|
-
# EOFError.
|
|
1646
|
+
# symbol <code>:wait_readable</code> instead. At EOF, it will return nil instead
|
|
1647
|
+
# of raising EOFError.
|
|
1570
1648
|
#
|
|
1571
|
-
def read_nonblock: (int len, ?string buf, ?exception: true) -> String
|
|
1572
|
-
| (int len, ?string buf, exception: false) -> (String | :wait_readable | nil)
|
|
1649
|
+
def read_nonblock: (int len, ?string? buf, ?exception: true) -> String
|
|
1650
|
+
| (int len, ?string? buf, exception: false) -> (String | :wait_readable | nil)
|
|
1573
1651
|
|
|
1574
1652
|
# <!--
|
|
1575
1653
|
# rdoc-file=io.c
|
|
@@ -1626,11 +1704,11 @@ class IO < Object
|
|
|
1626
1704
|
# - readlines(limit, chomp: false) -> array
|
|
1627
1705
|
# - readlines(sep, limit, chomp: false) -> array
|
|
1628
1706
|
# -->
|
|
1629
|
-
# Reads and returns all remaining line from the stream; does not modify
|
|
1630
|
-
# See [Line IO](rdoc-ref:IO@Line+IO).
|
|
1707
|
+
# Reads and returns all remaining line from the stream; does not modify
|
|
1708
|
+
# <code>$_</code>. See [Line IO](rdoc-ref:IO@Line+IO).
|
|
1631
1709
|
#
|
|
1632
|
-
# With no arguments given, returns lines as determined by line separator
|
|
1633
|
-
# or `nil` if none:
|
|
1710
|
+
# With no arguments given, returns lines as determined by line separator
|
|
1711
|
+
# <code>$/</code>, or `nil` if none:
|
|
1634
1712
|
#
|
|
1635
1713
|
# f = File.new('t.txt')
|
|
1636
1714
|
# f.readlines
|
|
@@ -1769,7 +1847,7 @@ class IO < Object
|
|
|
1769
1847
|
# r.readpartial(4096) # => "def\n" "" "ghi\n"
|
|
1770
1848
|
# r.readpartial(4096) # => "ghi\n" "" ""
|
|
1771
1849
|
#
|
|
1772
|
-
def readpartial: (int maxlen, ?string outbuf) -> String
|
|
1850
|
+
def readpartial: (int maxlen, ?string? outbuf) -> String
|
|
1773
1851
|
|
|
1774
1852
|
# <!--
|
|
1775
1853
|
# rdoc-file=io.c
|
|
@@ -1836,8 +1914,8 @@ class IO < Object
|
|
|
1836
1914
|
# Seeks to the position given by integer `offset` (see
|
|
1837
1915
|
# [Position](rdoc-ref:IO@Position)) and constant `whence`, which is one of:
|
|
1838
1916
|
#
|
|
1839
|
-
# *
|
|
1840
|
-
# plus the given `offset`:
|
|
1917
|
+
# * <code>:CUR</code> or <code>IO::SEEK_CUR</code>: Repositions the stream to
|
|
1918
|
+
# its current position plus the given `offset`:
|
|
1841
1919
|
#
|
|
1842
1920
|
# f = File.open('t.txt')
|
|
1843
1921
|
# f.tell # => 0
|
|
@@ -1847,8 +1925,8 @@ class IO < Object
|
|
|
1847
1925
|
# f.tell # => 10
|
|
1848
1926
|
# f.close
|
|
1849
1927
|
#
|
|
1850
|
-
# *
|
|
1851
|
-
# `offset`:
|
|
1928
|
+
# * <code>:END</code> or <code>IO::SEEK_END</code>: Repositions the stream to
|
|
1929
|
+
# its end plus the given `offset`:
|
|
1852
1930
|
#
|
|
1853
1931
|
# f = File.open('t.txt')
|
|
1854
1932
|
# f.tell # => 0
|
|
@@ -1860,7 +1938,8 @@ class IO < Object
|
|
|
1860
1938
|
# f.tell # => 12
|
|
1861
1939
|
# f.close
|
|
1862
1940
|
#
|
|
1863
|
-
# *
|
|
1941
|
+
# * <code>:SET</code> or <code>IO:SEEK_SET</code>: Repositions the stream to
|
|
1942
|
+
# the given `offset`:
|
|
1864
1943
|
#
|
|
1865
1944
|
# f = File.open('t.txt')
|
|
1866
1945
|
# f.tell # => 0
|
|
@@ -1888,7 +1967,7 @@ class IO < Object
|
|
|
1888
1967
|
# Argument `int_enc`, if given, must be an Encoding object or a String with the
|
|
1889
1968
|
# encoding name; it is assigned as the encoding for the internal string.
|
|
1890
1969
|
#
|
|
1891
|
-
# Argument
|
|
1970
|
+
# Argument <code>'ext_enc:int_enc'</code>, if given, is a string containing two
|
|
1892
1971
|
# colon-separated encoding names; corresponding Encoding objects are assigned as
|
|
1893
1972
|
# the external and internal encodings for the stream.
|
|
1894
1973
|
#
|
|
@@ -1989,7 +2068,7 @@ class IO < Object
|
|
|
1989
2068
|
#
|
|
1990
2069
|
# This method should not be used with other stream-reader methods.
|
|
1991
2070
|
#
|
|
1992
|
-
def sysread: (Integer maxlen, String outbuf) -> String
|
|
2071
|
+
def sysread: (Integer maxlen, ?String? outbuf) -> String
|
|
1993
2072
|
|
|
1994
2073
|
# <!--
|
|
1995
2074
|
# rdoc-file=io.c
|
|
@@ -2258,11 +2337,11 @@ class IO < Object
|
|
|
2258
2337
|
#
|
|
2259
2338
|
# On some platforms such as Windows, write_nonblock is not supported according
|
|
2260
2339
|
# to the kind of the IO object. In such cases, write_nonblock raises
|
|
2261
|
-
#
|
|
2340
|
+
# <code>Errno::EBADF</code>.
|
|
2262
2341
|
#
|
|
2263
2342
|
# By specifying a keyword argument *exception* to `false`, you can indicate that
|
|
2264
2343
|
# write_nonblock should not raise an IO::WaitWritable exception, but return the
|
|
2265
|
-
# symbol
|
|
2344
|
+
# symbol <code>:wait_writable</code> instead.
|
|
2266
2345
|
#
|
|
2267
2346
|
def write_nonblock: (_ToS s, ?exception: true) -> Integer
|
|
2268
2347
|
| (_ToS s, exception: false) -> (Integer | :wait_writable | nil)
|
|
@@ -2274,11 +2353,7 @@ class IO < Object
|
|
|
2274
2353
|
# Behaves like IO.read, except that the stream is opened in binary mode with
|
|
2275
2354
|
# ASCII-8BIT encoding.
|
|
2276
2355
|
#
|
|
2277
|
-
|
|
2278
|
-
# potential security vulnerabilities if called with untrusted input; see
|
|
2279
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2280
|
-
#
|
|
2281
|
-
def self.binread: (String name, ?Integer? length, ?Integer offset) -> String
|
|
2356
|
+
def self.binread: (path name, ?Integer? length, ?Integer offset) -> String
|
|
2282
2357
|
|
|
2283
2358
|
# <!--
|
|
2284
2359
|
# rdoc-file=io.c
|
|
@@ -2287,11 +2362,7 @@ class IO < Object
|
|
|
2287
2362
|
# Behaves like IO.write, except that the stream is opened in binary mode with
|
|
2288
2363
|
# ASCII-8BIT encoding.
|
|
2289
2364
|
#
|
|
2290
|
-
|
|
2291
|
-
# potential security vulnerabilities if called with untrusted input; see
|
|
2292
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2293
|
-
#
|
|
2294
|
-
def self.binwrite: (String name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
|
|
2365
|
+
def self.binwrite: (path name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
|
|
2295
2366
|
|
|
2296
2367
|
# <!--
|
|
2297
2368
|
# rdoc-file=io.c
|
|
@@ -2304,15 +2375,15 @@ class IO < Object
|
|
|
2304
2375
|
#
|
|
2305
2376
|
# * The path to a readable file, from which source data is to be read.
|
|
2306
2377
|
# * An IO-like object, opened for reading and capable of responding to
|
|
2307
|
-
# method
|
|
2378
|
+
# method <code>:readpartial</code> or method <code>:read</code>.
|
|
2308
2379
|
#
|
|
2309
2380
|
# * The given `dst` must be one of the following:
|
|
2310
2381
|
#
|
|
2311
2382
|
# * The path to a writable file, to which data is to be written.
|
|
2312
2383
|
# * An IO-like object, opened for writing and capable of responding to
|
|
2313
|
-
# method
|
|
2384
|
+
# method <code>:write</code>.
|
|
2314
2385
|
#
|
|
2315
|
-
# The examples here use file
|
|
2386
|
+
# The examples here use file <code>t.txt</code> as source:
|
|
2316
2387
|
#
|
|
2317
2388
|
# File.read('t.txt')
|
|
2318
2389
|
# # => "First line\nSecond line\n\nThird line\nFourth line\n"
|
|
@@ -2354,15 +2425,16 @@ class IO < Object
|
|
|
2354
2425
|
# connected to a new stream `io`.
|
|
2355
2426
|
#
|
|
2356
2427
|
# This method has potential security vulnerabilities if called with untrusted
|
|
2357
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2428
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2358
2429
|
#
|
|
2359
2430
|
# If no block is given, returns the new stream, which depending on given `mode`
|
|
2360
2431
|
# may be open for reading, writing, or both. The stream should be explicitly
|
|
2361
2432
|
# closed (eventually) to avoid resource leaks.
|
|
2362
2433
|
#
|
|
2363
2434
|
# If a block is given, the stream is passed to the block (again, open for
|
|
2364
|
-
# reading, writing, or both); when the block exits, the stream is closed,
|
|
2365
|
-
#
|
|
2435
|
+
# reading, writing, or both); when the block exits, the stream is closed, the
|
|
2436
|
+
# block's value is returned, and the global variable <code>$?</code> is set to
|
|
2437
|
+
# the child's exit status.
|
|
2366
2438
|
#
|
|
2367
2439
|
# Optional argument `mode` may be any valid IO mode. See [Access
|
|
2368
2440
|
# Modes](rdoc-ref:File@Access+Modes).
|
|
@@ -2391,10 +2463,10 @@ class IO < Object
|
|
|
2391
2463
|
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
|
2392
2464
|
# * Options for Kernel#spawn.
|
|
2393
2465
|
#
|
|
2394
|
-
# **Forked
|
|
2466
|
+
# **Forked Process**
|
|
2395
2467
|
#
|
|
2396
|
-
# When argument `cmd` is the 1-character string
|
|
2397
|
-
# fork:
|
|
2468
|
+
# When argument `cmd` is the 1-character string <code>'-'</code>, causes the
|
|
2469
|
+
# process to fork:
|
|
2398
2470
|
# IO.popen('-') do |pipe|
|
|
2399
2471
|
# if pipe
|
|
2400
2472
|
# $stderr.puts "In parent, child pid is #{pipe.pid}\n"
|
|
@@ -2412,8 +2484,8 @@ class IO < Object
|
|
|
2412
2484
|
#
|
|
2413
2485
|
# **Shell Subprocess**
|
|
2414
2486
|
#
|
|
2415
|
-
# When argument `cmd` is a single string (but not
|
|
2416
|
-
# `cmd` is run as a shell command:
|
|
2487
|
+
# When argument `cmd` is a single string (but not <code>'-'</code>), the program
|
|
2488
|
+
# named `cmd` is run as a shell command:
|
|
2417
2489
|
#
|
|
2418
2490
|
# IO.popen('uname') do |pipe|
|
|
2419
2491
|
# pipe.readlines
|
|
@@ -2437,8 +2509,8 @@ class IO < Object
|
|
|
2437
2509
|
#
|
|
2438
2510
|
# **Program Subprocess**
|
|
2439
2511
|
#
|
|
2440
|
-
# When argument `cmd` is an array of strings, the program named
|
|
2441
|
-
# with all elements of `cmd` as its arguments:
|
|
2512
|
+
# When argument `cmd` is an array of strings, the program named
|
|
2513
|
+
# <code>cmd[0]</code> is run with all elements of `cmd` as its arguments:
|
|
2442
2514
|
#
|
|
2443
2515
|
# IO.popen(['du', '..', '.']) do |pipe|
|
|
2444
2516
|
# $stderr.puts pipe.readlines.size
|
|
@@ -2448,18 +2520,19 @@ class IO < Object
|
|
|
2448
2520
|
#
|
|
2449
2521
|
# 1111
|
|
2450
2522
|
#
|
|
2451
|
-
#
|
|
2523
|
+
# <strong>Program Subprocess with `argv0`</strong>
|
|
2452
2524
|
#
|
|
2453
2525
|
# When argument `cmd` is an array whose first element is a 2-element string
|
|
2454
2526
|
# array and whose remaining elements (if any) are strings:
|
|
2455
2527
|
#
|
|
2456
|
-
# *
|
|
2457
|
-
# program that is run.
|
|
2458
|
-
# *
|
|
2459
|
-
# program's
|
|
2460
|
-
# *
|
|
2528
|
+
# * <code>cmd[0][0]</code> (the first string in the nested array) is the name
|
|
2529
|
+
# of a program that is run.
|
|
2530
|
+
# * <code>cmd[0][1]</code> (the second string in the nested array) is set as
|
|
2531
|
+
# the program's <code>argv[0]</code>.
|
|
2532
|
+
# * <code>cmd[1..-1]</code> (the strings in the outer array) are the program's
|
|
2533
|
+
# arguments.
|
|
2461
2534
|
#
|
|
2462
|
-
# Example (sets
|
|
2535
|
+
# Example (sets <code>$0</code> to 'foo'):
|
|
2463
2536
|
#
|
|
2464
2537
|
# IO.popen([['/bin/sh', 'foo'], '-c', 'echo $0']).read # => "foo\n"
|
|
2465
2538
|
#
|
|
@@ -2503,10 +2576,10 @@ class IO < Object
|
|
|
2503
2576
|
#
|
|
2504
2577
|
# Raises exceptions that IO.pipe and Kernel.spawn raise.
|
|
2505
2578
|
#
|
|
2506
|
-
def self.popen: (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others:
|
|
2507
|
-
| (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others:
|
|
2508
|
-
| [X] (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others:
|
|
2509
|
-
| [X] (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others:
|
|
2579
|
+
def self.popen: (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: bool, ?chdir: String) -> instance
|
|
2580
|
+
| (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: bool, ?chdir: String) -> instance
|
|
2581
|
+
| [X] (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: bool, ?chdir: String) { (instance) -> X } -> X
|
|
2582
|
+
| [X] (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: bool, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: bool, ?chdir: String) { (instance) -> X } -> X
|
|
2510
2583
|
|
|
2511
2584
|
# The command can be given as:
|
|
2512
2585
|
#
|
|
@@ -2526,10 +2599,6 @@ class IO < Object
|
|
|
2526
2599
|
# -->
|
|
2527
2600
|
# Calls the block with each successive line read from the stream.
|
|
2528
2601
|
#
|
|
2529
|
-
# When called from class IO (but not subclasses of IO), this method has
|
|
2530
|
-
# potential security vulnerabilities if called with untrusted input; see
|
|
2531
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2532
|
-
#
|
|
2533
2602
|
# The first argument must be a string that is the path to a file.
|
|
2534
2603
|
#
|
|
2535
2604
|
# With only argument `path` given, parses lines from the file at the given
|
|
@@ -2594,8 +2663,8 @@ class IO < Object
|
|
|
2594
2663
|
#
|
|
2595
2664
|
# Returns an Enumerator if no block is given.
|
|
2596
2665
|
#
|
|
2597
|
-
def self.foreach: (
|
|
2598
|
-
| (
|
|
2666
|
+
def self.foreach: (path path, ?String sep, ?Integer limit, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?chomp: boolish) { (String line) -> void } -> nil
|
|
2667
|
+
| (path path, ?String sep, ?Integer limit, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?chomp: boolish) -> ::Enumerator[String, nil]
|
|
2599
2668
|
|
|
2600
2669
|
# <!--
|
|
2601
2670
|
# rdoc-file=io.c
|
|
@@ -2651,8 +2720,8 @@ class IO < Object
|
|
|
2651
2720
|
# In the example below, the two processes close the ends of the pipe that they
|
|
2652
2721
|
# are not using. This is not just a cosmetic nicety. The read end of a pipe will
|
|
2653
2722
|
# not generate an end of file condition if there are any writers with the pipe
|
|
2654
|
-
# still open. In the case of the parent process, the
|
|
2655
|
-
# if it does not first issue a
|
|
2723
|
+
# still open. In the case of the parent process, the <code>rd.read</code> will
|
|
2724
|
+
# never return if it does not first issue a <code>wr.close</code>:
|
|
2656
2725
|
#
|
|
2657
2726
|
# rd, wr = IO.pipe
|
|
2658
2727
|
#
|
|
@@ -2668,7 +2737,7 @@ class IO < Object
|
|
|
2668
2737
|
# wr.close
|
|
2669
2738
|
# end
|
|
2670
2739
|
#
|
|
2671
|
-
#
|
|
2740
|
+
# <em>produces:</em>
|
|
2672
2741
|
#
|
|
2673
2742
|
# Sending message to parent
|
|
2674
2743
|
# Parent got: <Hi Dad>
|
|
@@ -2683,10 +2752,6 @@ class IO < Object
|
|
|
2683
2752
|
# Opens the stream, reads and returns some or all of its content, and closes the
|
|
2684
2753
|
# stream; returns `nil` if no bytes were read.
|
|
2685
2754
|
#
|
|
2686
|
-
# When called from class IO (but not subclasses of IO), this method has
|
|
2687
|
-
# potential security vulnerabilities if called with untrusted input; see
|
|
2688
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2689
|
-
#
|
|
2690
2755
|
# The first argument must be a string that is the path to a file.
|
|
2691
2756
|
#
|
|
2692
2757
|
# With only argument `path` given, reads in text mode and returns the entire
|
|
@@ -2716,7 +2781,7 @@ class IO < Object
|
|
|
2716
2781
|
# * [Open Options](rdoc-ref:IO@Open+Options).
|
|
2717
2782
|
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
|
2718
2783
|
#
|
|
2719
|
-
def self.read: (
|
|
2784
|
+
def self.read: (path name, ?Integer? length, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> String
|
|
2720
2785
|
|
|
2721
2786
|
# <!--
|
|
2722
2787
|
# rdoc-file=io.c
|
|
@@ -2726,10 +2791,6 @@ class IO < Object
|
|
|
2726
2791
|
# -->
|
|
2727
2792
|
# Returns an array of all lines read from the stream.
|
|
2728
2793
|
#
|
|
2729
|
-
# When called from class IO (but not subclasses of IO), this method has
|
|
2730
|
-
# potential security vulnerabilities if called with untrusted input; see
|
|
2731
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2732
|
-
#
|
|
2733
2794
|
# The first argument must be a string that is the path to a file.
|
|
2734
2795
|
#
|
|
2735
2796
|
# With only argument `path` given, parses lines from the file at the given
|
|
@@ -2769,7 +2830,7 @@ class IO < Object
|
|
|
2769
2830
|
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
|
2770
2831
|
# * [Line Options](rdoc-ref:IO@Line+IO).
|
|
2771
2832
|
#
|
|
2772
|
-
def self.readlines: (
|
|
2833
|
+
def self.readlines: (path name, ?String sep, ?Integer limit, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?chomp: boolish) -> ::Array[String]
|
|
2773
2834
|
|
|
2774
2835
|
# <!--
|
|
2775
2836
|
# rdoc-file=io.c
|
|
@@ -2785,7 +2846,9 @@ class IO < Object
|
|
|
2785
2846
|
# IO objects.
|
|
2786
2847
|
#
|
|
2787
2848
|
# Argument `timeout` is a numeric value (such as integer or float) timeout
|
|
2788
|
-
# interval in seconds.
|
|
2849
|
+
# interval in seconds. `timeout` can also be `nil` or
|
|
2850
|
+
# <code>Float::INFINITY</code>. `nil` and <code>Float::INFINITY</code> means no
|
|
2851
|
+
# timeout.
|
|
2789
2852
|
#
|
|
2790
2853
|
# The method monitors the IO objects given in all three arrays, waiting for some
|
|
2791
2854
|
# to be ready; returns a 3-element array whose elements are:
|
|
@@ -2860,8 +2923,8 @@ class IO < Object
|
|
|
2860
2923
|
#
|
|
2861
2924
|
# The writability notified by select(2) doesn't show how many bytes are
|
|
2862
2925
|
# writable. IO#write method blocks until given whole string is written. So,
|
|
2863
|
-
#
|
|
2864
|
-
# IO.select. IO#write_nonblock is required to avoid the blocking.
|
|
2926
|
+
# <code>IO#write(two or more bytes)</code> can block after writability is
|
|
2927
|
+
# notified by IO.select. IO#write_nonblock is required to avoid the blocking.
|
|
2865
2928
|
#
|
|
2866
2929
|
# Blocking write (#write) can be emulated using #write_nonblock and IO.select as
|
|
2867
2930
|
# follows: IO::WaitReadable should also be rescued for SSL renegotiation in
|
|
@@ -2950,10 +3013,6 @@ class IO < Object
|
|
|
2950
3013
|
# Opens the stream, writes the given `data` to it, and closes the stream;
|
|
2951
3014
|
# returns the number of bytes written.
|
|
2952
3015
|
#
|
|
2953
|
-
# When called from class IO (but not subclasses of IO), this method has
|
|
2954
|
-
# potential security vulnerabilities if called with untrusted input; see
|
|
2955
|
-
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2956
|
-
#
|
|
2957
3016
|
# The first argument must be a string that is the path to a file.
|
|
2958
3017
|
#
|
|
2959
3018
|
# With only argument `path` given, writes the given `data` to the file at that
|
|
@@ -2976,7 +3035,7 @@ class IO < Object
|
|
|
2976
3035
|
# File.read('t.tmp') # => "ab012f"
|
|
2977
3036
|
#
|
|
2978
3037
|
# If `offset` is outside the file content, the file is padded with null
|
|
2979
|
-
# characters
|
|
3038
|
+
# characters <code>"\u0000"</code>:
|
|
2980
3039
|
#
|
|
2981
3040
|
# IO.write('t.tmp', 'xyz', 10) # => 3
|
|
2982
3041
|
# File.read('t.tmp') # => "ab012f\u0000\u0000\u0000\u0000xyz"
|
|
@@ -2986,7 +3045,7 @@ class IO < Object
|
|
|
2986
3045
|
# * [Open Options](rdoc-ref:IO@Open+Options).
|
|
2987
3046
|
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
|
2988
3047
|
#
|
|
2989
|
-
def self.write: (
|
|
3048
|
+
def self.write: (path path, _ToS data, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> Integer
|
|
2990
3049
|
|
|
2991
3050
|
# <!--
|
|
2992
3051
|
# rdoc-file=io.c
|
|
@@ -3015,7 +3074,8 @@ class IO < Object
|
|
|
3015
3074
|
# Calls the block with each remaining line read from the stream; returns `self`.
|
|
3016
3075
|
# Does nothing if already at end-of-stream; See [Line IO](rdoc-ref:IO@Line+IO).
|
|
3017
3076
|
#
|
|
3018
|
-
# With no arguments given, reads lines as determined by line separator
|
|
3077
|
+
# With no arguments given, reads lines as determined by line separator
|
|
3078
|
+
# <code>$/</code>:
|
|
3019
3079
|
#
|
|
3020
3080
|
# f = File.new('t.txt')
|
|
3021
3081
|
# f.each_line {|line| p line }
|
|
@@ -3117,7 +3177,8 @@ class IO < Object
|
|
|
3117
3177
|
# Calls the block with each remaining line read from the stream; returns `self`.
|
|
3118
3178
|
# Does nothing if already at end-of-stream; See [Line IO](rdoc-ref:IO@Line+IO).
|
|
3119
3179
|
#
|
|
3120
|
-
# With no arguments given, reads lines as determined by line separator
|
|
3180
|
+
# With no arguments given, reads lines as determined by line separator
|
|
3181
|
+
# <code>$/</code>:
|
|
3121
3182
|
#
|
|
3122
3183
|
# f = File.new('t.txt')
|
|
3123
3184
|
# f.each_line {|line| p line }
|
|
@@ -3404,3 +3465,9 @@ end
|
|
|
3404
3465
|
#
|
|
3405
3466
|
module IO::WaitWritable
|
|
3406
3467
|
end
|
|
3468
|
+
|
|
3469
|
+
# <!-- rdoc-file=io.c -->
|
|
3470
|
+
# Can be raised by IO operations when IO#timeout= is set.
|
|
3471
|
+
#
|
|
3472
|
+
class IO::TimeoutError < IOError
|
|
3473
|
+
end
|