rbs 4.0.0.dev.5 → 4.0.1.dev.1

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.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +1 -0
  3. data/.github/workflows/c-check.yml +8 -4
  4. data/.github/workflows/comments.yml +3 -1
  5. data/.github/workflows/dependabot.yml +1 -1
  6. data/.github/workflows/ruby.yml +10 -0
  7. data/.github/workflows/rust.yml +95 -0
  8. data/CHANGELOG.md +323 -0
  9. data/Rakefile +12 -29
  10. data/Steepfile +1 -0
  11. data/config.yml +393 -37
  12. data/core/array.rbs +218 -188
  13. data/core/basic_object.rbs +9 -8
  14. data/core/class.rbs +6 -5
  15. data/core/comparable.rbs +45 -31
  16. data/core/complex.rbs +52 -40
  17. data/core/dir.rbs +57 -45
  18. data/core/encoding.rbs +5 -5
  19. data/core/enumerable.rbs +96 -91
  20. data/core/enumerator.rbs +4 -3
  21. data/core/errno.rbs +3 -2
  22. data/core/errors.rbs +31 -29
  23. data/core/exception.rbs +12 -12
  24. data/core/fiber.rbs +36 -36
  25. data/core/file.rbs +186 -113
  26. data/core/file_test.rbs +2 -2
  27. data/core/float.rbs +41 -32
  28. data/core/gc.rbs +78 -70
  29. data/core/hash.rbs +70 -60
  30. data/core/integer.rbs +32 -28
  31. data/core/io/buffer.rbs +36 -36
  32. data/core/io/wait.rbs +7 -7
  33. data/core/io.rbs +120 -135
  34. data/core/kernel.rbs +189 -139
  35. data/core/marshal.rbs +3 -3
  36. data/core/match_data.rbs +14 -12
  37. data/core/math.rbs +69 -67
  38. data/core/method.rbs +6 -6
  39. data/core/module.rbs +146 -85
  40. data/core/nil_class.rbs +4 -3
  41. data/core/numeric.rbs +35 -32
  42. data/core/object.rbs +6 -8
  43. data/core/object_space.rbs +11 -10
  44. data/core/pathname.rbs +131 -81
  45. data/core/proc.rbs +65 -33
  46. data/core/process.rbs +219 -201
  47. data/core/ractor.rbs +15 -11
  48. data/core/random.rbs +4 -3
  49. data/core/range.rbs +52 -47
  50. data/core/rational.rbs +5 -5
  51. data/core/rbs/unnamed/argf.rbs +58 -51
  52. data/core/rbs/unnamed/env_class.rbs +18 -13
  53. data/core/rbs/unnamed/main_class.rbs +123 -0
  54. data/core/rbs/unnamed/random.rbs +7 -5
  55. data/core/regexp.rbs +236 -197
  56. data/core/ruby.rbs +1 -1
  57. data/core/ruby_vm.rbs +32 -30
  58. data/core/rubygems/config_file.rbs +5 -5
  59. data/core/rubygems/errors.rbs +1 -1
  60. data/core/rubygems/requirement.rbs +5 -5
  61. data/core/rubygems/rubygems.rbs +5 -3
  62. data/core/set.rbs +17 -16
  63. data/core/signal.rbs +2 -2
  64. data/core/string.rbs +311 -292
  65. data/core/struct.rbs +26 -25
  66. data/core/symbol.rbs +25 -24
  67. data/core/thread.rbs +40 -34
  68. data/core/time.rbs +47 -42
  69. data/core/trace_point.rbs +34 -31
  70. data/core/true_class.rbs +2 -2
  71. data/core/unbound_method.rbs +10 -10
  72. data/core/warning.rbs +7 -7
  73. data/docs/collection.md +1 -1
  74. data/docs/config.md +171 -0
  75. data/docs/inline.md +110 -4
  76. data/docs/syntax.md +13 -12
  77. data/ext/rbs_extension/ast_translation.c +489 -135
  78. data/ext/rbs_extension/class_constants.c +8 -0
  79. data/ext/rbs_extension/class_constants.h +4 -0
  80. data/ext/rbs_extension/legacy_location.c +28 -51
  81. data/ext/rbs_extension/legacy_location.h +37 -0
  82. data/ext/rbs_extension/main.c +12 -20
  83. data/include/rbs/ast.h +423 -195
  84. data/include/rbs/lexer.h +2 -2
  85. data/include/rbs/location.h +25 -44
  86. data/include/rbs/parser.h +2 -2
  87. data/include/rbs/util/rbs_constant_pool.h +0 -3
  88. data/include/rbs.h +8 -0
  89. data/lib/rbs/ast/ruby/annotations.rb +157 -4
  90. data/lib/rbs/ast/ruby/members.rb +374 -22
  91. data/lib/rbs/cli/validate.rb +5 -60
  92. data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
  93. data/lib/rbs/definition_builder.rb +60 -27
  94. data/lib/rbs/errors.rb +0 -11
  95. data/lib/rbs/inline_parser.rb +1 -1
  96. data/lib/rbs/parser_aux.rb +20 -7
  97. data/lib/rbs/prototype/helpers.rb +57 -0
  98. data/lib/rbs/prototype/rb.rb +1 -26
  99. data/lib/rbs/prototype/rbi.rb +1 -20
  100. data/lib/rbs/test/type_check.rb +3 -0
  101. data/lib/rbs/types.rb +62 -52
  102. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  103. data/lib/rbs/version.rb +1 -1
  104. data/lib/rbs.rb +0 -1
  105. data/rbs.gemspec +1 -1
  106. data/rust/.gitignore +1 -0
  107. data/rust/Cargo.lock +378 -0
  108. data/rust/Cargo.toml +7 -0
  109. data/rust/ruby-rbs/Cargo.toml +22 -0
  110. data/rust/ruby-rbs/build.rs +764 -0
  111. data/rust/ruby-rbs/examples/locations.rs +60 -0
  112. data/rust/ruby-rbs/src/lib.rs +1 -0
  113. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  114. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  115. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  116. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  117. data/rust/ruby-rbs-sys/build.rs +204 -0
  118. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  119. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  120. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  121. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  122. data/sig/ast/ruby/annotations.rbs +191 -4
  123. data/sig/ast/ruby/members.rbs +21 -1
  124. data/sig/cli/validate.rbs +1 -6
  125. data/sig/definition_builder.rbs +2 -0
  126. data/sig/errors.rbs +0 -8
  127. data/sig/method_types.rbs +1 -1
  128. data/sig/parser.rbs +17 -13
  129. data/sig/prototype/helpers.rbs +2 -0
  130. data/sig/types.rbs +10 -11
  131. data/sig/unit_test/spy.rbs +0 -8
  132. data/sig/unit_test/type_assertions.rbs +11 -0
  133. data/src/ast.c +339 -161
  134. data/src/lexstate.c +1 -1
  135. data/src/location.c +7 -47
  136. data/src/parser.c +674 -480
  137. data/src/util/rbs_constant_pool.c +0 -4
  138. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
  139. data/stdlib/cgi-escape/0/escape.rbs +4 -4
  140. data/stdlib/coverage/0/coverage.rbs +4 -3
  141. data/stdlib/date/0/date.rbs +33 -28
  142. data/stdlib/date/0/date_time.rbs +24 -23
  143. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  144. data/stdlib/erb/0/erb.rbs +64 -53
  145. data/stdlib/etc/0/etc.rbs +55 -50
  146. data/stdlib/fileutils/0/fileutils.rbs +138 -125
  147. data/stdlib/forwardable/0/forwardable.rbs +10 -10
  148. data/stdlib/io-console/0/io-console.rbs +2 -2
  149. data/stdlib/json/0/json.rbs +135 -108
  150. data/stdlib/monitor/0/monitor.rbs +3 -3
  151. data/stdlib/net-http/0/net-http.rbs +159 -134
  152. data/stdlib/objspace/0/objspace.rbs +8 -7
  153. data/stdlib/open-uri/0/open-uri.rbs +8 -8
  154. data/stdlib/open3/0/open3.rbs +36 -35
  155. data/stdlib/openssl/0/openssl.rbs +144 -129
  156. data/stdlib/optparse/0/optparse.rbs +18 -14
  157. data/stdlib/pathname/0/pathname.rbs +2 -2
  158. data/stdlib/pp/0/pp.rbs +9 -8
  159. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  160. data/stdlib/pstore/0/pstore.rbs +35 -30
  161. data/stdlib/psych/0/psych.rbs +61 -8
  162. data/stdlib/psych/0/store.rbs +2 -4
  163. data/stdlib/pty/0/pty.rbs +9 -6
  164. data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
  165. data/stdlib/ripper/0/ripper.rbs +20 -17
  166. data/stdlib/securerandom/0/securerandom.rbs +1 -1
  167. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  168. data/stdlib/socket/0/addrinfo.rbs +7 -7
  169. data/stdlib/socket/0/basic_socket.rbs +3 -3
  170. data/stdlib/socket/0/ip_socket.rbs +10 -8
  171. data/stdlib/socket/0/socket.rbs +10 -9
  172. data/stdlib/socket/0/tcp_server.rbs +1 -1
  173. data/stdlib/socket/0/tcp_socket.rbs +1 -1
  174. data/stdlib/socket/0/udp_socket.rbs +1 -1
  175. data/stdlib/socket/0/unix_server.rbs +1 -1
  176. data/stdlib/stringio/0/stringio.rbs +55 -54
  177. data/stdlib/strscan/0/string_scanner.rbs +46 -44
  178. data/stdlib/tempfile/0/tempfile.rbs +24 -20
  179. data/stdlib/time/0/time.rbs +7 -5
  180. data/stdlib/tsort/0/tsort.rbs +7 -6
  181. data/stdlib/uri/0/common.rbs +26 -18
  182. data/stdlib/uri/0/file.rbs +2 -2
  183. data/stdlib/uri/0/generic.rbs +2 -2
  184. data/stdlib/uri/0/http.rbs +2 -2
  185. data/stdlib/uri/0/ldap.rbs +2 -2
  186. data/stdlib/uri/0/mailto.rbs +3 -3
  187. data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
  188. data/stdlib/zlib/0/deflate.rbs +4 -3
  189. data/stdlib/zlib/0/gzip_reader.rbs +4 -4
  190. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  191. data/stdlib/zlib/0/inflate.rbs +1 -1
  192. data/stdlib/zlib/0/need_dict.rbs +1 -1
  193. metadata +23 -5
  194. data/.github/workflows/valgrind.yml +0 -42
@@ -325,7 +325,7 @@ class BasicSocket < IO
325
325
  #
326
326
  # By specifying a keyword argument *exception* to `false`, you can indicate that
327
327
  # recv_nonblock should not raise an IO::WaitReadable exception, but return the
328
- # symbol `:wait_readable` instead.
328
+ # symbol <code>:wait_readable</code> instead.
329
329
  #
330
330
  # ### See
331
331
  # * Socket#recvfrom
@@ -399,7 +399,7 @@ class BasicSocket < IO
399
399
  #
400
400
  # By specifying a keyword argument *exception* to `false`, you can indicate that
401
401
  # recvmsg_nonblock should not raise an IO::WaitReadable exception, but return
402
- # the symbol `:wait_readable` instead.
402
+ # the symbol <code>:wait_readable</code> instead.
403
403
  #
404
404
  def recvmsg_nonblock: (?Integer dlen, ?Integer flags, ?Integer clen, ?exception: boolish, ?scm_rights: boolish) -> ([ String, Addrinfo, Integer?, Array[Socket::AncillaryData] ] | :wait_readable)
405
405
 
@@ -487,7 +487,7 @@ class BasicSocket < IO
487
487
  #
488
488
  # By specifying a keyword argument *exception* to `false`, you can indicate that
489
489
  # sendmsg_nonblock should not raise an IO::WaitWritable exception, but return
490
- # the symbol `:wait_writable` instead.
490
+ # the symbol <code>:wait_writable</code> instead.
491
491
  #
492
492
  def sendmsg_nonblock: (String mesg, ?Integer flags, ?Addrinfo | String dest_sockaddr, *Socket::AncillaryData controls, ?exception: boolish) -> (Integer | :wait_writable)
493
493
 
@@ -22,10 +22,11 @@ class IPSocket < BasicSocket
22
22
  # Returns the local address as an array which contains address_family, port,
23
23
  # hostname and numeric_address.
24
24
  #
25
- # If `reverse_lookup` is `true` or `:hostname`, hostname is obtained from
26
- # numeric_address using reverse lookup. Or if it is `false`, or `:numeric`,
27
- # hostname is the same as numeric_address. Or if it is `nil` or omitted, obeys
28
- # to `ipsocket.do_not_reverse_lookup`. See `Socket.getaddrinfo` also.
25
+ # If `reverse_lookup` is `true` or <code>:hostname</code>, hostname is obtained
26
+ # from numeric_address using reverse lookup. Or if it is `false`, or
27
+ # <code>:numeric</code>, hostname is the same as numeric_address. Or if it is
28
+ # `nil` or omitted, obeys to <code>ipsocket.do_not_reverse_lookup</code>. See
29
+ # <code>Socket.getaddrinfo</code> also.
29
30
  #
30
31
  # TCPSocket.open("www.ruby-lang.org", 80) {|sock|
31
32
  # p sock.addr #=> ["AF_INET", 49429, "hal", "192.168.0.128"]
@@ -53,10 +54,11 @@ class IPSocket < BasicSocket
53
54
  # hostname and numeric_address. It is defined for connection oriented socket
54
55
  # such as TCPSocket.
55
56
  #
56
- # If `reverse_lookup` is `true` or `:hostname`, hostname is obtained from
57
- # numeric_address using reverse lookup. Or if it is `false`, or `:numeric`,
58
- # hostname is the same as numeric_address. Or if it is `nil` or omitted, obeys
59
- # to `ipsocket.do_not_reverse_lookup`. See `Socket.getaddrinfo` also.
57
+ # If `reverse_lookup` is `true` or <code>:hostname</code>, hostname is obtained
58
+ # from numeric_address using reverse lookup. Or if it is `false`, or
59
+ # <code>:numeric</code>, hostname is the same as numeric_address. Or if it is
60
+ # `nil` or omitted, obeys to <code>ipsocket.do_not_reverse_lookup</code>. See
61
+ # <code>Socket.getaddrinfo</code> also.
60
62
  #
61
63
  # TCPSocket.open("www.ruby-lang.org", 80) {|sock|
62
64
  # p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"]
@@ -16,20 +16,21 @@
16
16
  #
17
17
  # Sockets have their own vocabulary:
18
18
  #
19
- # **domain:** The family of protocols:
19
+ # <strong>domain:</strong> The family of protocols:
20
20
  # * Socket::PF_INET
21
21
  # * Socket::PF_INET6
22
22
  # * Socket::PF_UNIX
23
23
  # * etc.
24
24
  #
25
- # **type:** The type of communications between the two endpoints, typically
25
+ # <strong>type:</strong> The type of communications between the two endpoints,
26
+ # typically
26
27
  # * Socket::SOCK_STREAM
27
28
  # * Socket::SOCK_DGRAM.
28
29
  #
29
- # **protocol:** Typically *zero*. This may be used to identify a variant of a
30
- # protocol.
30
+ # <strong>protocol:</strong> Typically *zero*. This may be used to identify a
31
+ # variant of a protocol.
31
32
  #
32
- # **hostname:** The identifier of a network interface:
33
+ # <strong>hostname:</strong> The identifier of a network interface:
33
34
  # * a string (hostname, IPv4 or IPv6 address or `broadcast` which specifies a
34
35
  # broadcast address)
35
36
  # * a zero-length string which specifies INADDR_ANY
@@ -484,7 +485,7 @@ class Socket < BasicSocket
484
485
  # The `connect_timeout` specifies the timeout in seconds from the start of
485
486
  # the connection attempt to the last candidate.
486
487
  # By default, all connection attempts continue until the timeout occurs.
487
- # When `fast_fallback:false` is explicitly specified,
488
+ # When <code>fast_fallback:false</code> is explicitly specified,
488
489
  # a timeout is set for each connection attempt and any connection attempt
489
490
  # that exceeds its timeout will be canceled.
490
491
  #
@@ -845,7 +846,7 @@ class Socket < BasicSocket
845
846
  #
846
847
  # By specifying a keyword argument *exception* to `false`, you can indicate that
847
848
  # accept_nonblock should not raise an IO::WaitReadable exception, but return the
848
- # symbol `:wait_readable` instead.
849
+ # symbol <code>:wait_readable</code> instead.
849
850
  #
850
851
  # ### See
851
852
  # * Socket#accept
@@ -1099,7 +1100,7 @@ class Socket < BasicSocket
1099
1100
  #
1100
1101
  # By specifying a keyword argument *exception* to `false`, you can indicate that
1101
1102
  # connect_nonblock should not raise an IO::WaitWritable exception, but return
1102
- # the symbol `:wait_writable` instead.
1103
+ # the symbol <code>:wait_writable</code> instead.
1103
1104
  #
1104
1105
  # ### See
1105
1106
  # * Socket#connect
@@ -1357,7 +1358,7 @@ class Socket < BasicSocket
1357
1358
  #
1358
1359
  # By specifying a keyword argument *exception* to `false`, you can indicate that
1359
1360
  # recvfrom_nonblock should not raise an IO::WaitReadable exception, but return
1360
- # the symbol `:wait_readable` instead.
1361
+ # the symbol <code>:wait_readable</code> instead.
1361
1362
  #
1362
1363
  # ### See
1363
1364
  # * Socket#recvfrom
@@ -72,7 +72,7 @@ class TCPServer < TCPSocket
72
72
  #
73
73
  # By specifying a keyword argument *exception* to `false`, you can indicate that
74
74
  # accept_nonblock should not raise an IO::WaitReadable exception, but return the
75
- # symbol `:wait_readable` instead.
75
+ # symbol <code>:wait_readable</code> instead.
76
76
  #
77
77
  # ### See
78
78
  # * TCPServer#accept
@@ -68,7 +68,7 @@ class TCPSocket < IPSocket
68
68
  # The `connect_timeout` specifies the timeout in seconds from the start of
69
69
  # the connection attempt to the last candidate.
70
70
  # By default, all connection attempts continue until the timeout occurs.
71
- # When `fast_fallback:false` is explicitly specified,
71
+ # When <code>fast_fallback:false</code> is explicitly specified,
72
72
  # a timeout is set for each connection attempt and any connection attempt
73
73
  # that exceeds its timeout will be canceled.
74
74
  #
@@ -81,7 +81,7 @@ class UDPSocket < IPSocket
81
81
  #
82
82
  # By specifying a keyword argument *exception* to `false`, you can indicate that
83
83
  # recvfrom_nonblock should not raise an IO::WaitReadable exception, but return
84
- # the symbol `:wait_readable` instead.
84
+ # the symbol <code>:wait_readable</code> instead.
85
85
  #
86
86
  # ### See
87
87
  # * Socket#recvfrom
@@ -50,7 +50,7 @@ class UNIXServer < UNIXSocket
50
50
  #
51
51
  # By specifying a keyword argument *exception* to `false`, you can indicate that
52
52
  # accept_nonblock should not raise an IO::WaitReadable exception, but return the
53
- # symbol `:wait_readable` instead.
53
+ # symbol <code>:wait_readable</code> instead.
54
54
  #
55
55
  # ### See
56
56
  # * UNIXServer#accept
@@ -6,8 +6,8 @@
6
6
  # * StringIO.new: returns a new StringIO object containing the given string.
7
7
  # * StringIO.open: passes a new StringIO object to the given block.
8
8
  # Like an IO stream, a StringIO stream has certain properties:
9
- # * **Read/write mode**: whether the stream may be read, written, appended to,
10
- # etc.;
9
+ # * <strong>Read/write mode</strong>: whether the stream may be read, written,
10
+ # appended to, etc.;
11
11
  # see [Read/Write Mode](rdoc-ref:StringIO@Read-2FWrite+Mode).
12
12
  # * **Data mode**: text-only or binary;
13
13
  # see [Data Mode](rdoc-ref:StringIO@Data+Mode).
@@ -18,8 +18,8 @@
18
18
  # * **Line number**: a special, line-oriented, "position" (different from the
19
19
  # position mentioned above);
20
20
  # see [Line Number](rdoc-ref:StringIO@Line+Number).
21
- # * **Open/closed**: whether the stream is open or closed, for reading or
22
- # writing.
21
+ # * <strong>Open/closed</strong>: whether the stream is open or closed, for
22
+ # reading or writing.
23
23
  # see [Open/Closed Streams](rdoc-ref:StringIO@Open-2FClosed+Streams).
24
24
  # * **BOM**: byte mark order;
25
25
  # see [Byte Order Mark](rdoc-ref:StringIO@BOM+-28Byte+Order+Mark-29).
@@ -39,24 +39,24 @@
39
39
  # ## Stream Properties
40
40
  # ### Read/Write Mode
41
41
  # #### Summary
42
- # Mode |Initial Clear?| Read | Write
43
- # -------------------|--------------|--------|--------
44
- # `'r'`: read-only | No |Anywhere| Error
45
- # `'w'`: write-only | Yes | Error |Anywhere
46
- # `'a'`: append-only | No | Error |End only
47
- # `'r+'`: read/write | No |Anywhere|Anywhere
48
- # `'w+'`: read-write | Yes |Anywhere|Anywhere
49
- # `'a+'`: read/append| No |Anywhere|End only
42
+ # Mode |Initial Clear?| Read | Write
43
+ # ------------------------------|--------------|--------|--------
44
+ # <code>'r'</code>: read-only | No |Anywhere| Error
45
+ # <code>'w'</code>: write-only | Yes | Error |Anywhere
46
+ # <code>'a'</code>: append-only | No | Error |End only
47
+ # <code>'r+'</code>: read/write | No |Anywhere|Anywhere
48
+ # <code>'w+'</code>: read-write | Yes |Anywhere|Anywhere
49
+ # <code>'a+'</code>: read/append| No |Anywhere|End only
50
50
  # Each section below describes a read/write mode.
51
51
  # Any of the modes may be given as a string or as file constants;
52
52
  # example:
53
53
  # strio = StringIO.new('foo', 'a')
54
54
  # strio = StringIO.new('foo', File::WRONLY | File::APPEND)
55
55
  #
56
- # #### `'r'`: Read-Only
56
+ # #### <code>'r'</code>: Read-Only
57
57
  # Mode specified as one of:
58
- # * String: `'r'`.
59
- # * Constant: `File::RDONLY`.
58
+ # * String: <code>'r'</code>.
59
+ # * Constant: <code>File::RDONLY</code>.
60
60
  # Initial state:
61
61
  # strio = StringIO.new('foobarbaz', 'r')
62
62
  # strio.pos # => 0 # Beginning-of-stream.
@@ -71,10 +71,10 @@
71
71
  # May not be written:
72
72
  # strio.write('foo') # Raises IOError: not opened for writing
73
73
  #
74
- # #### `'w'`: Write-Only
74
+ # #### <code>'w'</code>: Write-Only
75
75
  # Mode specified as one of:
76
- # * String: `'w'`.
77
- # * Constant: `File::WRONLY`.
76
+ # * String: <code>'w'</code>.
77
+ # * Constant: <code>File::WRONLY</code>.
78
78
  # Initial state:
79
79
  # strio = StringIO.new('foo', 'w')
80
80
  # strio.pos # => 0 # Beginning of stream.
@@ -96,10 +96,10 @@
96
96
  # May not be read:
97
97
  # strio.read # Raises IOError: not opened for reading
98
98
  #
99
- # #### `'a'`: Append-Only
99
+ # #### <code>'a'</code>: Append-Only
100
100
  # Mode specified as one of:
101
- # * String: `'a'`.
102
- # * Constant: `File::WRONLY | File::APPEND`.
101
+ # * String: <code>'a'</code>.
102
+ # * Constant: <code>File::WRONLY | File::APPEND</code>.
103
103
  # Initial state:
104
104
  # strio = StringIO.new('foo', 'a')
105
105
  # strio.pos # => 0 # Beginning-of-stream.
@@ -117,10 +117,10 @@
117
117
  # May not be read:
118
118
  # strio.gets # Raises IOError: not opened for reading
119
119
  #
120
- # #### `'r+'`: Read/Write
120
+ # #### <code>'r+'</code>: Read/Write
121
121
  # Mode specified as one of:
122
- # * String: `'r+'`.
123
- # * Constant: `File::RDRW`.
122
+ # * String: <code>'r+'</code>.
123
+ # * Constant: <code>File::RDRW</code>.
124
124
  # Initial state:
125
125
  # strio = StringIO.new('foobar', 'r+')
126
126
  # strio.pos # => 0 # Beginning-of-stream.
@@ -145,10 +145,10 @@
145
145
  # strio.pos = 400
146
146
  # strio.gets(3) # => nil
147
147
  #
148
- # #### `'w+'`: Read/Write (Initially Clear)
148
+ # #### <code>'w+'</code>: Read/Write (Initially Clear)
149
149
  # Mode specified as one of:
150
- # * String: `'w+'`.
151
- # * Constant: `File::RDWR | File::TRUNC`.
150
+ # * String: <code>'w+'</code>.
151
+ # * Constant: <code>File::RDWR | File::TRUNC</code>.
152
152
  # Initial state:
153
153
  # strio = StringIO.new('foo', 'w+')
154
154
  # strio.pos # => 0 # Beginning-of-stream.
@@ -177,10 +177,10 @@
177
177
  # strio.pos = 400
178
178
  # strio.gets(3) # => nil
179
179
  #
180
- # #### `'a+'`: Read/Append
180
+ # #### <code>'a+'</code>: Read/Append
181
181
  # Mode specified as one of:
182
- # * String: `'a+'`.
183
- # * Constant: `File::RDWR | File::APPEND`.
182
+ # * String: <code>'a+'</code>.
183
+ # * Constant: <code>File::RDWR | File::APPEND</code>.
184
184
  # Initial state:
185
185
  # strio = StringIO.new('foo', 'a+')
186
186
  # strio.pos # => 0 # Beginning-of-stream.
@@ -208,9 +208,9 @@
208
208
  # To specify whether the stream is to be treated as text or as binary data,
209
209
  # either of the following may be suffixed to any of the string read/write modes
210
210
  # above:
211
- # * `'t'`: Text;
211
+ # * <code>'t'</code>: Text;
212
212
  # initializes the encoding as Encoding::UTF_8.
213
- # * `'b'`: Binary;
213
+ # * <code>'b'</code>: Binary;
214
214
  # initializes the encoding as Encoding::ASCII_8BIT.
215
215
  # If neither is given, the stream defaults to text data.
216
216
  # Examples:
@@ -231,12 +231,12 @@
231
231
  # .
232
232
  # The initial encoding for a new or re-opened stream depends on its [data
233
233
  # mode](rdoc-ref:StringIO@Data+Mode):
234
- # * Text: `Encoding::UTF_8`.
235
- # * Binary: `Encoding::ASCII_8BIT`.
234
+ # * Text: <code>Encoding::UTF_8</code>.
235
+ # * Binary: <code>Encoding::ASCII_8BIT</code>.
236
236
  # These instance methods are relevant:
237
237
  # * #external_encoding: returns the current encoding of the stream as an
238
238
  # `Encoding` object.
239
- # * #internal_encoding: returns `nil`; a stream does not have an internal
239
+ # * #internal_encoding: returns +nil+; a stream does not have an internal
240
240
  # encoding.
241
241
  # * #set_encoding: sets the encoding for the stream.
242
242
  # * #set_encoding_by_bom: sets the encoding for the stream to the stream's BOM
@@ -371,7 +371,7 @@
371
371
  # * Method #lineno= sets the line number.
372
372
  # The line number can be affected by reading (but never by writing);
373
373
  # in general, the line number is incremented each time the record separator
374
- # (default: `"\n"`) is read.
374
+ # (default: <code>"\n"</code>) is read.
375
375
  # Examples:
376
376
  # strio = StringIO.new(TEXT)
377
377
  # strio.string # => "First line\nSecond line\n\nFourth line\nFifth line\n"
@@ -522,7 +522,7 @@ class StringIO
522
522
  # strio.closed_write? # => false
523
523
  # strio.close
524
524
  #
525
- # If `string` is frozen, the default `mode` is `'r'`:
525
+ # If `string` is frozen, the default `mode` is <code>'r'</code>:
526
526
  #
527
527
  # strio = StringIO.new('foo'.freeze)
528
528
  # strio.string # => "foo"
@@ -546,7 +546,8 @@ class StringIO
546
546
  # - StringIO.open(string = '', mode = 'r+') -> new_stringio
547
547
  # - StringIO.open(string = '', mode = 'r+') {|strio| ... } -> object
548
548
  # -->
549
- # Creates new StringIO instance by calling `StringIO.new(string, mode)`.
549
+ # Creates new StringIO instance by calling <code>StringIO.new(string,
550
+ # mode)</code>.
550
551
  #
551
552
  # With no block given, returns the new instance:
552
553
  #
@@ -685,7 +686,7 @@ class StringIO
685
686
  # **No Arguments**
686
687
  # With no arguments given,
687
688
  # reads lines using the default record separator
688
- # (global variable `$/`, whose initial value is `"\n"`).
689
+ # (global variable <code>$/</code>, whose initial value is <code>"\n"</code>).
689
690
  # strio = StringIO.new(TEXT)
690
691
  # strio.each_line {|line| p line }
691
692
  # strio.eof? # => true
@@ -697,7 +698,7 @@ class StringIO
697
698
  # "Fourth line\n"
698
699
  # "Fifth line\n"
699
700
  #
700
- # **Argument `sep`**
701
+ # <strong>Argument `sep`</strong>
701
702
  # With only string argument `sep` given,
702
703
  # reads lines using that string as the record separator:
703
704
  # strio = StringIO.new(TEXT)
@@ -710,7 +711,7 @@ class StringIO
710
711
  # "line\nFifth "
711
712
  # "line\n"
712
713
  #
713
- # **Argument `limit`**
714
+ # <strong>Argument `limit`</strong>
714
715
  # With only integer argument `limit` given,
715
716
  # reads lines using the default record separator;
716
717
  # also limits the size (in characters) of each line to the given limit:
@@ -728,7 +729,7 @@ class StringIO
728
729
  # "Fifth line"
729
730
  # "\n"
730
731
  #
731
- # **Arguments `sep` and `limit`**
732
+ # <strong>Arguments `sep` and `limit`</strong>
732
733
  # With arguments `sep` and `limit` both given,
733
734
  # honors both:
734
735
  # strio = StringIO.new(TEXT)
@@ -793,7 +794,7 @@ class StringIO
793
794
  # Output:
794
795
  # "First line\nSecond line\n\nFourth line\nFifth line\n"
795
796
  #
796
- # **Keyword Argument `chomp`**
797
+ # <strong>Keyword Argument `chomp`</strong>
797
798
  # With keyword argument `chomp` given as `true` (the default is `false`),
798
799
  # removes trailing newline (if any) from each line:
799
800
  # strio = StringIO.new(TEXT)
@@ -1085,10 +1086,10 @@ class StringIO
1085
1086
  # Side effects:
1086
1087
  #
1087
1088
  # * Increments stream position by the number of bytes read.
1088
- # * Assigns the return value to global variable `$_`.
1089
+ # * Assigns the return value to global variable <code>$_</code>.
1089
1090
  #
1090
1091
  # With no arguments given, reads a line using the default record separator
1091
- # (global variable `$/`,* whose initial value is `"\n"`):
1092
+ # (global variable <code>$/</code>,* whose initial value is <code>"\n"</code>):
1092
1093
  #
1093
1094
  # strio = StringIO.new(TEXT)
1094
1095
  # strio.pos # => 0
@@ -1105,7 +1106,7 @@ class StringIO
1105
1106
  # strio.gets # => "Привет"
1106
1107
  # strio.pos # => 12
1107
1108
  #
1108
- # **Argument `sep`**
1109
+ # <strong>Argument `sep`</strong>
1109
1110
  #
1110
1111
  # With only string argument `sep` given, reads a line using that string as the
1111
1112
  # record separator:
@@ -1115,7 +1116,7 @@ class StringIO
1115
1116
  # strio.gets(' ') # => "line\nSecond "
1116
1117
  # strio.gets(' ') # => "line\n\nFourth "
1117
1118
  #
1118
- # **Argument `limit`**
1119
+ # <strong>Argument `limit`</strong>
1119
1120
  #
1120
1121
  # With only integer argument `limit` given, reads a line using the default
1121
1122
  # record separator; limits the size (in characters) of each line to the given
@@ -1127,7 +1128,7 @@ class StringIO
1127
1128
  # strio.gets(10) # => "Second lin"
1128
1129
  # strio.gets(10) # => "e\n"
1129
1130
  #
1130
- # **Arguments `sep` and `limit`**
1131
+ # <strong>Arguments `sep` and `limit`</strong>
1131
1132
  #
1132
1133
  # With arguments `sep` and `limit` both given, honors both:
1133
1134
  #
@@ -1170,7 +1171,7 @@ class StringIO
1170
1171
  # strio.gets(nil) # "Slurp": read all.
1171
1172
  # # => "First line\nSecond line\n\nFourth line\nFifth line\n"
1172
1173
  #
1173
- # **Keyword Argument `chomp`**
1174
+ # <strong>Keyword Argument `chomp`</strong>
1174
1175
  #
1175
1176
  # With keyword argument `chomp` given as `true` (the default is `false`),
1176
1177
  # removes the trailing newline (if any) from the returned line:
@@ -1507,7 +1508,7 @@ class StringIO
1507
1508
  # **No Arguments**
1508
1509
  # With no arguments given,
1509
1510
  # reads lines using the default record separator
1510
- # (global variable `$/`, whose initial value is `"\n"`).
1511
+ # (global variable <code>$/</code>, whose initial value is <code>"\n"</code>).
1511
1512
  # strio = StringIO.new(TEXT)
1512
1513
  # strio.each_line {|line| p line }
1513
1514
  # strio.eof? # => true
@@ -1519,7 +1520,7 @@ class StringIO
1519
1520
  # "Fourth line\n"
1520
1521
  # "Fifth line\n"
1521
1522
  #
1522
- # **Argument `sep`**
1523
+ # <strong>Argument `sep`</strong>
1523
1524
  # With only string argument `sep` given,
1524
1525
  # reads lines using that string as the record separator:
1525
1526
  # strio = StringIO.new(TEXT)
@@ -1532,7 +1533,7 @@ class StringIO
1532
1533
  # "line\nFifth "
1533
1534
  # "line\n"
1534
1535
  #
1535
- # **Argument `limit`**
1536
+ # <strong>Argument `limit`</strong>
1536
1537
  # With only integer argument `limit` given,
1537
1538
  # reads lines using the default record separator;
1538
1539
  # also limits the size (in characters) of each line to the given limit:
@@ -1550,7 +1551,7 @@ class StringIO
1550
1551
  # "Fifth line"
1551
1552
  # "\n"
1552
1553
  #
1553
- # **Arguments `sep` and `limit`**
1554
+ # <strong>Arguments `sep` and `limit`</strong>
1554
1555
  # With arguments `sep` and `limit` both given,
1555
1556
  # honors both:
1556
1557
  # strio = StringIO.new(TEXT)
@@ -1615,7 +1616,7 @@ class StringIO
1615
1616
  # Output:
1616
1617
  # "First line\nSecond line\n\nFourth line\nFifth line\n"
1617
1618
  #
1618
- # **Keyword Argument `chomp`**
1619
+ # <strong>Keyword Argument `chomp`</strong>
1619
1620
  # With keyword argument `chomp` given as `true` (the default is `false`),
1620
1621
  # removes trailing newline (if any) from each line:
1621
1622
  # strio = StringIO.new(TEXT)