rbs 3.0.0.dev.2 → 3.0.0.dev.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -1
  3. data/.github/workflows/ruby.yml +4 -0
  4. data/Gemfile.lock +11 -11
  5. data/Rakefile +2 -2
  6. data/Steepfile +1 -1
  7. data/core/array.rbs +573 -423
  8. data/core/basic_object.rbs +11 -39
  9. data/core/binding.rbs +1 -1
  10. data/core/builtin.rbs +8 -0
  11. data/core/class.rbs +37 -0
  12. data/core/comparable.rbs +7 -18
  13. data/core/complex.rbs +2 -2
  14. data/core/data.rbs +419 -0
  15. data/core/dir.rbs +52 -104
  16. data/core/encoding.rbs +22 -181
  17. data/core/enumerable.rbs +212 -175
  18. data/core/enumerator/product.rbs +96 -0
  19. data/core/enumerator.rbs +57 -8
  20. data/core/errors.rbs +8 -2
  21. data/core/exception.rbs +41 -0
  22. data/core/fiber.rbs +95 -12
  23. data/core/file.rbs +840 -275
  24. data/core/file_test.rbs +34 -19
  25. data/core/float.rbs +40 -96
  26. data/core/gc.rbs +15 -3
  27. data/core/hash.rbs +113 -175
  28. data/core/integer.rbs +85 -145
  29. data/core/io/buffer.rbs +187 -60
  30. data/core/io/wait.rbs +28 -16
  31. data/core/io.rbs +1859 -1389
  32. data/core/kernel.rbs +525 -961
  33. data/core/match_data.rbs +306 -142
  34. data/core/math.rbs +506 -234
  35. data/core/method.rbs +0 -24
  36. data/core/module.rbs +110 -17
  37. data/core/nil_class.rbs +2 -0
  38. data/core/numeric.rbs +76 -144
  39. data/core/object.rbs +88 -212
  40. data/core/proc.rbs +17 -5
  41. data/core/process.rbs +22 -5
  42. data/core/ractor.rbs +1 -1
  43. data/core/random.rbs +20 -3
  44. data/core/range.rbs +91 -89
  45. data/core/rational.rbs +2 -3
  46. data/core/rbs/unnamed/argf.rbs +177 -120
  47. data/core/rbs/unnamed/env_class.rbs +89 -163
  48. data/core/rbs/unnamed/random.rbs +36 -12
  49. data/core/refinement.rbs +8 -0
  50. data/core/regexp.rbs +462 -272
  51. data/core/ruby_vm.rbs +210 -0
  52. data/{stdlib/set/0 → core}/set.rbs +43 -47
  53. data/core/string.rbs +1403 -1332
  54. data/core/string_io.rbs +191 -107
  55. data/core/struct.rbs +67 -63
  56. data/core/symbol.rbs +187 -201
  57. data/core/thread.rbs +40 -35
  58. data/core/time.rbs +902 -826
  59. data/core/trace_point.rbs +55 -6
  60. data/core/unbound_method.rbs +48 -24
  61. data/docs/collection.md +4 -0
  62. data/docs/syntax.md +55 -0
  63. data/ext/rbs_extension/parser.c +5 -6
  64. data/lib/rbs/cli.rb +6 -1
  65. data/lib/rbs/collection/cleaner.rb +8 -1
  66. data/lib/rbs/collection/config/lockfile.rb +3 -1
  67. data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
  68. data/lib/rbs/collection/config.rb +1 -1
  69. data/lib/rbs/collection/sources/git.rb +9 -2
  70. data/lib/rbs/collection/sources/local.rb +79 -0
  71. data/lib/rbs/collection/sources.rb +8 -1
  72. data/lib/rbs/environment.rb +6 -5
  73. data/lib/rbs/environment_loader.rb +3 -2
  74. data/lib/rbs/errors.rb +18 -0
  75. data/lib/rbs/locator.rb +26 -7
  76. data/lib/rbs/sorter.rb +2 -2
  77. data/lib/rbs/version.rb +1 -1
  78. data/sig/collection/sources.rbs +32 -3
  79. data/sig/environment.rbs +2 -3
  80. data/sig/locator.rbs +14 -2
  81. data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
  82. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
  83. data/stdlib/cgi/0/core.rbs +16 -0
  84. data/stdlib/coverage/0/coverage.rbs +50 -8
  85. data/stdlib/csv/0/csv.rbs +1 -1
  86. data/stdlib/date/0/date.rbs +856 -726
  87. data/stdlib/date/0/date_time.rbs +83 -210
  88. data/stdlib/erb/0/erb.rbs +13 -36
  89. data/stdlib/etc/0/etc.rbs +127 -20
  90. data/stdlib/fileutils/0/fileutils.rbs +1290 -381
  91. data/stdlib/logger/0/logger.rbs +466 -316
  92. data/stdlib/net-http/0/net-http.rbs +2211 -534
  93. data/stdlib/nkf/0/nkf.rbs +5 -5
  94. data/stdlib/objspace/0/objspace.rbs +31 -14
  95. data/stdlib/openssl/0/openssl.rbs +11 -7
  96. data/stdlib/optparse/0/optparse.rbs +20 -17
  97. data/stdlib/pathname/0/pathname.rbs +21 -4
  98. data/stdlib/pstore/0/pstore.rbs +378 -154
  99. data/stdlib/pty/0/pty.rbs +24 -8
  100. data/stdlib/ripper/0/ripper.rbs +1650 -0
  101. data/stdlib/socket/0/addrinfo.rbs +9 -15
  102. data/stdlib/socket/0/socket.rbs +36 -3
  103. data/stdlib/strscan/0/string_scanner.rbs +7 -5
  104. data/stdlib/tempfile/0/tempfile.rbs +104 -44
  105. data/stdlib/time/0/time.rbs +2 -2
  106. data/stdlib/uri/0/file.rbs +5 -0
  107. data/stdlib/uri/0/generic.rbs +2 -2
  108. data/stdlib/yaml/0/yaml.rbs +2 -2
  109. data/stdlib/zlib/0/zlib.rbs +1 -1
  110. metadata +8 -6
  111. data/core/deprecated.rbs +0 -9
  112. data/sig/shims/ripper.rbs +0 -8
data/core/symbol.rbs CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # You can create a Symbol object explicitly with:
5
5
  #
6
- # * A [symbol literal](doc/syntax/literals_rdoc.html#label-Symbol+Literals).
6
+ # * A [symbol literal](rdoc-ref:syntax/literals.rdoc@Symbol+Literals).
7
7
  #
8
8
  #
9
9
  # The same Symbol object will be created for a given name or string for the
@@ -59,125 +59,77 @@
59
59
  #
60
60
  # First, what's elsewhere. Class Symbol:
61
61
  #
62
- # * Inherits from [class
63
- # Object](Object.html#class-Object-label-What-27s+Here).
64
- # * Includes [module
65
- # Comparable](Comparable.html#module-Comparable-label-What-27s+Here).
62
+ # * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
63
+ # * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
66
64
  #
67
65
  #
68
66
  # Here, class Symbol provides methods that are useful for:
69
67
  #
70
- # * [Querying](#class-Symbol-label-Methods+for+Querying)
71
- # * [Comparing](#class-Symbol-label-Methods+for+Comparing)
72
- # * [Converting](#class-Symbol-label-Methods+for+Converting)
68
+ # * [Querying](rdoc-ref:Symbol@Methods+for+Querying)
69
+ # * [Comparing](rdoc-ref:Symbol@Methods+for+Comparing)
70
+ # * [Converting](rdoc-ref:Symbol@Methods+for+Converting)
73
71
  #
74
72
  #
75
73
  # ### Methods for Querying
76
74
  #
77
- # ::all_symbols
78
- # : Returns an array of the symbols currently in Ruby's symbol table.
79
- #
80
- # [#=~](#method-i-3D~)
81
- # : Returns the index of the first substring in symbol that matches a
82
- # given Regexp or other object; returns `nil` if no match is found.
83
- #
84
- # #[], #slice
85
- # : Returns a substring of symbol determined by a given index,
86
- # start/length, or range, or string.
87
- #
88
- # #empty?
89
- # : Returns `true` if `self.length` is zero; `false` otherwise.
90
- #
91
- # #encoding
92
- # : Returns the Encoding object that represents the encoding of symbol.
93
- #
94
- # #end_with?
95
- # : Returns `true` if symbol ends with any of the given strings.
96
- #
97
- # #match
98
- # : Returns a MatchData object if symbol matches a given Regexp; `nil`
99
- # otherwise.
100
- #
101
- # #match?
102
- # : Returns `true` if symbol matches a given Regexp; `false` otherwise.
103
- #
104
- # #length, #size
105
- # : Returns the number of characters in symbol.
106
- #
107
- # #start_with?
108
- # : Returns `true` if symbol starts with any of the given strings.
109
- #
75
+ # * ::all_symbols: Returns an array of the symbols currently in Ruby's symbol
76
+ # table.
77
+ # * #=~: Returns the index of the first substring in symbol that matches a
78
+ # given Regexp or other object; returns `nil` if no match is found.
79
+ # * #[], #slice : Returns a substring of symbol determined by a given index,
80
+ # start/length, or range, or string.
81
+ # * #empty?: Returns `true` if `self.length` is zero; `false` otherwise.
82
+ # * #encoding: Returns the Encoding object that represents the encoding of
83
+ # symbol.
84
+ # * #end_with?: Returns `true` if symbol ends with any of the given strings.
85
+ # * #match: Returns a MatchData object if symbol matches a given Regexp; `nil`
86
+ # otherwise.
87
+ # * #match?: Returns `true` if symbol matches a given Regexp; `false`
88
+ # otherwise.
89
+ # * #length, #size: Returns the number of characters in symbol.
90
+ # * #start_with?: Returns `true` if symbol starts with any of the given
91
+ # strings.
110
92
  #
111
93
  #
112
94
  # ### Methods for Comparing
113
95
  #
114
- # [#<=>](#method-i-3C-3D-3E)
115
- # : Returns -1, 0, or 1 as a given symbol is smaller than, equal to, or
116
- # larger than symbol.
117
- #
118
- # [#==, #===](#method-i-3D-3D)
119
- # : Returns `true` if a given symbol has the same content and encoding.
120
- #
121
- # #casecmp
122
- # : Ignoring case, returns -1, 0, or 1 as a given symbol is smaller than,
123
- # equal to, or larger than symbol.
124
- #
125
- # #casecmp?
126
- # : Returns `true` if symbol is equal to a given symbol after Unicode case
127
- # folding; `false` otherwise.
128
- #
96
+ # * #<=>: Returns -1, 0, or 1 as a given symbol is smaller than, equal to, or
97
+ # larger than symbol.
98
+ # * #==, #===: Returns `true` if a given symbol has the same content and
99
+ # encoding.
100
+ # * #casecmp: Ignoring case, returns -1, 0, or 1 as a given symbol is smaller
101
+ # than, equal to, or larger than symbol.
102
+ # * #casecmp?: Returns `true` if symbol is equal to a given symbol after
103
+ # Unicode case folding; `false` otherwise.
129
104
  #
130
105
  #
131
106
  # ### Methods for Converting
132
107
  #
133
- # #capitalize
134
- # : Returns symbol with the first character upcased and all other
135
- # characters downcased.
136
- #
137
- # #downcase
138
- # : Returns symbol with all characters downcased.
139
- #
140
- # #inspect
141
- # : Returns the string representation of `self` as a symbol literal.
142
- #
143
- # #name
144
- # : Returns the frozen string corresponding to symbol.
145
- #
146
- # #succ, #next
147
- # : Returns the symbol that is the successor to symbol.
148
- #
149
- # #swapcase
150
- # : Returns symbol with all upcase characters downcased and all downcase
151
- # characters upcased.
152
- #
153
- # #to_proc
154
- # : Returns a Proc object which responds to the method named by symbol.
155
- #
156
- # #to_s, #id2name
157
- # : Returns the string corresponding to `self`.
158
- #
159
- # #to_sym, #intern
160
- # : Returns `self`.
161
- #
162
- # #upcase
163
- # : Returns symbol with all characters upcased.
108
+ # * #capitalize: Returns symbol with the first character upcased and all other
109
+ # characters downcased.
110
+ # * #downcase: Returns symbol with all characters downcased.
111
+ # * #inspect: Returns the string representation of `self` as a symbol literal.
112
+ # * #name: Returns the frozen string corresponding to symbol.
113
+ # * #succ, #next: Returns the symbol that is the successor to symbol.
114
+ # * #swapcase: Returns symbol with all upcase characters downcased and all
115
+ # downcase characters upcased.
116
+ # * #to_proc: Returns a Proc object which responds to the method named by
117
+ # symbol.
118
+ # * #to_s, #id2name: Returns the string corresponding to `self`.
119
+ # * #to_sym, #intern: Returns `self`.
120
+ # * #upcase: Returns symbol with all characters upcased.
164
121
  #
165
122
  class Symbol
166
123
  include Comparable
167
124
 
168
125
  # <!--
169
126
  # rdoc-file=string.c
170
- # - Symbol.all_symbols => array
127
+ # - Symbol.all_symbols -> array_of_symbols
171
128
  # -->
172
- # Returns an array of all the symbols currently in Ruby's symbol table.
129
+ # Returns an array of all symbols currently in Ruby's symbol table:
173
130
  #
174
- # Symbol.all_symbols.size #=> 903
175
- # Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
176
- # :chown, :EOFError, :$;, :String,
177
- # :LOCK_SH, :"setuid?", :$<,
178
- # :default_proc, :compact, :extend,
179
- # :Tms, :getwd, :$=, :ThreadGroup,
180
- # :wait2, :$>]
131
+ # Symbol.all_symbols.size # => 9334
132
+ # Symbol.all_symbols.take(3) # => [:!, :"\"", :"#"]
181
133
  #
182
134
  def self.all_symbols: () -> ::Array[Symbol]
183
135
 
@@ -185,48 +137,59 @@ class Symbol
185
137
 
186
138
  # <!--
187
139
  # rdoc-file=string.c
188
- # - symbol <=> other_symbol -> -1, 0, +1, or nil
140
+ # - symbol <=> object -> -1, 0, +1, or nil
189
141
  # -->
190
- # Compares `symbol` with `other_symbol` after calling #to_s on each of the
191
- # symbols. Returns -1, 0, +1, or `nil` depending on whether `symbol` is less
192
- # than, equal to, or greater than `other_symbol`.
142
+ # If `object` is a symbol, returns the equivalent of `symbol.to_s <=>
143
+ # object.to_s`:
144
+ #
145
+ # :bar <=> :foo # => -1
146
+ # :foo <=> :foo # => 0
147
+ # :foo <=> :bar # => 1
148
+ #
149
+ # Otherwise, returns `nil`:
193
150
  #
194
- # `nil` is returned if the two values are incomparable.
151
+ # :foo <=> 'bar' # => nil
195
152
  #
196
- # See String#<=> for more information.
153
+ # Related: String#<=>.
197
154
  #
198
155
  def <=>: (Symbol other) -> Integer
199
156
  | (untyped other) -> Integer?
200
157
 
201
158
  # <!--
202
159
  # rdoc-file=string.c
203
- # - sym == obj -> true or false
160
+ # - symbol == object -> true or false
204
161
  # -->
205
- # Equality---If *sym* and *obj* are exactly the same symbol, returns `true`.
162
+ # Returns `true` if `object` is the same object as `self`, `false` otherwise.
163
+ #
164
+ # Symbol#=== is an alias for Symbol#==.
206
165
  #
207
166
  def ==: (untyped obj) -> bool
208
167
 
209
168
  # <!-- rdoc-file=string.c -->
210
- # Equality---If *sym* and *obj* are exactly the same symbol, returns `true`.
169
+ # Returns `true` if `object` is the same object as `self`, `false` otherwise.
170
+ #
171
+ # Symbol#=== is an alias for Symbol#==.
211
172
  #
212
173
  def ===: (untyped obj) -> bool
213
174
 
214
175
  # <!--
215
176
  # rdoc-file=string.c
216
- # - sym =~ obj -> integer or nil
177
+ # - symbol =~ object -> integer or nil
217
178
  # -->
218
- # Returns `sym.to_s =~ obj`.
179
+ # Equivalent to `symbol.to_s =~ object`, including possible updates to global
180
+ # variables; see String#=~.
219
181
  #
220
182
  def =~: (untyped obj) -> Integer?
221
183
 
222
184
  # <!--
223
185
  # rdoc-file=string.c
224
- # - sym[idx] -> char
225
- # - sym[b, n] -> string
226
- # - sym.slice(idx) -> char
227
- # - sym.slice(b, n) -> string
186
+ # - symbol[index] -> string or nil
187
+ # - symbol[start, length] -> string or nil
188
+ # - symbol[range] -> string or nil
189
+ # - symbol[regexp, capture = 0] -> string or nil
190
+ # - symbol[substring] -> string or nil
228
191
  # -->
229
- # Returns `sym.to_s[]`.
192
+ # Equivalent to `symbol.to_s[]`; see String#[].
230
193
  #
231
194
  def []: (int index) -> String?
232
195
  | (int start, int length) -> String?
@@ -250,54 +213,68 @@ class Symbol
250
213
 
251
214
  # <!--
252
215
  # rdoc-file=string.c
253
- # - casecmp(other_symbol) -> -1, 0, 1, or nil
216
+ # - casecmp(object) -> -1, 0, 1, or nil
254
217
  # -->
255
- # Case-insensitive version of [Symbol#<=>](#method-i-3C-3D-3E):
218
+ # Like Symbol#<=>, but case-insensitive; equivalent to
219
+ # `self.to_s.casecmp(object.to_s)`:
256
220
  #
257
- # :aBcDeF.casecmp(:abcde) # => 1
258
- # :aBcDeF.casecmp(:abcdef) # => 0
259
- # :aBcDeF.casecmp(:abcdefg) # => -1
260
- # :abcdef.casecmp(:ABCDEF) # => 0
221
+ # lower = :abc
222
+ # upper = :ABC
223
+ # upper.casecmp(lower) # => 0
224
+ # lower.casecmp(lower) # => 0
225
+ # lower.casecmp(upper) # => 0
261
226
  #
262
- # Returns `nil` if the two symbols have incompatible encodings, or if
263
- # `other_symbol` is not a symbol:
227
+ # Returns nil if `self` and `object` have incompatible encodings, or if `object`
228
+ # is not a symbol:
264
229
  #
265
- # sym = "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym
266
- # other_sym = :"\u{c4 d6 dc}"
230
+ # sym = 'äöü'.encode("ISO-8859-1").to_sym
231
+ # other_sym = 'ÄÖÜ'
267
232
  # sym.casecmp(other_sym) # => nil
268
233
  # :foo.casecmp(2) # => nil
269
234
  #
270
- # Currently, case-insensitivity only works on characters A-Z/a-z, not all of
271
- # Unicode. This is different from Symbol#casecmp?.
235
+ # Unlike Symbol#casecmp?, case-insensitivity does not work for characters
236
+ # outside of 'A'..'Z' and 'a'..'z':
272
237
  #
273
- # Related: Symbol#casecmp?.
238
+ # lower = :äöü
239
+ # upper = :ÄÖÜ
240
+ # upper.casecmp(lower) # => -1
241
+ # lower.casecmp(lower) # => 0
242
+ # lower.casecmp(upper) # => 1
243
+ #
244
+ # Related: Symbol#casecmp?, String#casecmp.
274
245
  #
275
246
  def casecmp: (untyped other) -> Integer?
276
247
 
277
248
  # <!--
278
249
  # rdoc-file=string.c
279
- # - casecmp?(other_symbol) -> true, false, or nil
250
+ # - casecmp?(object) -> true, false, or nil
280
251
  # -->
281
- # Returns `true` if `sym` and `other_symbol` are equal after Unicode case
282
- # folding, `false` if they are not equal:
252
+ # Returns `true` if `self` and `object` are equal after Unicode case folding,
253
+ # otherwise `false`:
283
254
  #
284
- # :aBcDeF.casecmp?(:abcde) # => false
285
- # :aBcDeF.casecmp?(:abcdef) # => true
286
- # :aBcDeF.casecmp?(:abcdefg) # => false
287
- # :abcdef.casecmp?(:ABCDEF) # => true
288
- # :"\u{e4 f6 fc}".casecmp?(:"\u{c4 d6 dc}") #=> true
255
+ # lower = :abc
256
+ # upper = :ABC
257
+ # upper.casecmp?(lower) # => true
258
+ # lower.casecmp?(lower) # => true
259
+ # lower.casecmp?(upper) # => true
289
260
  #
290
- # Returns `nil` if the two symbols have incompatible encodings, or if
291
- # `other_symbol` is not a symbol:
261
+ # Returns nil if `self` and `object` have incompatible encodings, or if `object`
262
+ # is not a symbol:
292
263
  #
293
- # sym = "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym
294
- # other_sym = :"\u{c4 d6 dc}"
264
+ # sym = 'äöü'.encode("ISO-8859-1").to_sym
265
+ # other_sym = 'ÄÖÜ'
295
266
  # sym.casecmp?(other_sym) # => nil
296
267
  # :foo.casecmp?(2) # => nil
297
268
  #
298
- # See [Case Mapping](doc/case_mapping_rdoc.html).
269
+ # Unlike Symbol#casecmp, works for characters outside of 'A'..'Z' and 'a'..'z':
270
+ #
271
+ # lower = :äöü
272
+ # upper = :ÄÖÜ
273
+ # upper.casecmp?(lower) # => true
274
+ # lower.casecmp?(lower) # => true
275
+ # lower.casecmp?(upper) # => true
299
276
  #
300
- # Related: Symbol#casecmp.
277
+ # Related: Symbol#casecmp, String#casecmp?.
301
278
  #
302
279
  def casecmp?: (untyped other) -> bool?
303
280
 
@@ -318,129 +295,129 @@ class Symbol
318
295
 
319
296
  # <!--
320
297
  # rdoc-file=string.c
321
- # - sym.empty? -> true or false
298
+ # - empty? -> true or false
322
299
  # -->
323
- # Returns whether *sym* is :"" or not.
300
+ # Returns `true` if `self` is `:''`, `false` otherwise.
324
301
  #
325
302
  def empty?: () -> bool
326
303
 
327
304
  # <!--
328
305
  # rdoc-file=string.c
329
- # - sym.encoding -> encoding
306
+ # - encoding -> encoding
330
307
  # -->
331
- # Returns the Encoding object that represents the encoding of *sym*.
308
+ # Equivalent to `self.to_s.encoding`; see String#encoding.
332
309
  #
333
310
  def encoding: () -> Encoding
334
311
 
335
312
  # <!--
336
313
  # rdoc-file=string.c
337
- # - sym.end_with?([suffixes]+) -> true or false
314
+ # - end_with?(*string_or_regexp) -> true or false
338
315
  # -->
339
- # Returns true if `sym` ends with one of the `suffixes` given.
340
- #
341
- # :hello.end_with?("ello") #=> true
342
- #
343
- # # returns true if one of the +suffixes+ matches.
344
- # :hello.end_with?("heaven", "ello") #=> true
345
- # :hello.end_with?("heaven", "paradise") #=> false
316
+ # Equivalent to `self.to_s.end_with?`; see String#end_with?.
346
317
  #
347
318
  def end_with?: (*string suffixes) -> bool
348
319
 
349
320
  # <!-- rdoc-file=string.c -->
350
- # Returns the name or string corresponding to *sym*.
321
+ # Returns a string representation of `self` (not including the leading colon):
322
+ #
323
+ # :foo.to_s # => "foo"
351
324
  #
352
- # :fred.id2name #=> "fred"
353
- # :ginger.to_s #=> "ginger"
325
+ # Symbol#id2name is an alias for Symbol#to_s.
354
326
  #
355
- # Note that this string is not frozen (unlike the symbol itself). To get a
356
- # frozen string, use #name.
327
+ # Related: Symbol#inspect, Symbol#name.
357
328
  #
358
329
  def id2name: () -> String
359
330
 
360
331
  # <!--
361
332
  # rdoc-file=string.c
362
- # - sym.inspect -> string
333
+ # - inspect -> string
363
334
  # -->
364
- # Returns the representation of *sym* as a symbol literal.
335
+ # Returns a string representation of `self` (including the leading colon):
365
336
  #
366
- # :fred.inspect #=> ":fred"
337
+ # :foo.inspect # => ":foo"
338
+ #
339
+ # Related: Symbol#to_s, Symbol#name.
367
340
  #
368
341
  def inspect: () -> String
369
342
 
370
343
  # <!--
371
- # rdoc-file=string.c
372
- # - sym.to_sym -> sym
373
- # - sym.intern -> sym
344
+ # rdoc-file=symbol.rb
345
+ # - intern()
374
346
  # -->
375
- # In general, `to_sym` returns the Symbol corresponding to an object. As *sym*
376
- # is already a symbol, `self` is returned in this case.
377
347
  #
378
348
  def intern: () -> Symbol
379
349
 
380
350
  # <!--
381
351
  # rdoc-file=string.c
382
- # - sym.length -> integer
383
- # - sym.size -> integer
352
+ # - length -> integer
384
353
  # -->
385
- # Same as `sym.to_s.length`.
354
+ # Equivalent to `self.to_s.length`; see String#length.
355
+ #
356
+ # Symbol#size is an alias for Symbol#length.
386
357
  #
387
358
  def length: () -> Integer
388
359
 
389
360
  # <!--
390
361
  # rdoc-file=string.c
391
- # - sym.match(pattern) -> matchdata or nil
392
- # - sym.match(pattern, pos) -> matchdata or nil
362
+ # - match(pattern, offset = 0) -> matchdata or nil
363
+ # - match(pattern, offset = 0) {|matchdata| } -> object
393
364
  # -->
394
- # Returns `sym.to_s.match`.
365
+ # Equivalent to `self.to_s.match`, including possible updates to global
366
+ # variables; see String#match.
395
367
  #
396
368
  def match: (Regexp | string pattern, ?int pos) -> MatchData?
397
369
  | (Regexp | string pattern, ?int pos) { (MatchData) -> void } -> untyped
398
370
 
399
371
  # <!--
400
372
  # rdoc-file=string.c
401
- # - sym.match?(pattern) -> true or false
402
- # - sym.match?(pattern, pos) -> true or false
373
+ # - match?(pattern, offset) -> true or false
403
374
  # -->
404
- # Returns `sym.to_s.match?`.
375
+ # Equivalent to `sym.to_s.match?`; see String#match.
405
376
  #
406
377
  def match?: (Regexp | string pattern, ?int pos) -> bool
407
378
 
408
379
  # <!-- rdoc-file=string.c -->
409
- # Same as `sym.to_s.succ.intern`.
380
+ # Equivalent to `self.to_s.succ.to_sym`:
381
+ #
382
+ # :foo.succ # => :fop
383
+ #
384
+ # Symbol#next is an alias for Symbol#succ.
385
+ #
386
+ # Related: String#succ.
410
387
  #
411
388
  def next: () -> Symbol
412
389
 
413
390
  # <!-- rdoc-file=string.c -->
414
- # Same as `sym.to_s.length`.
391
+ # Equivalent to `self.to_s.length`; see String#length.
392
+ #
393
+ # Symbol#size is an alias for Symbol#length.
415
394
  #
416
395
  alias size length
417
396
 
418
397
  # <!-- rdoc-file=string.c -->
419
- # Returns `sym.to_s[]`.
398
+ # Equivalent to `symbol.to_s[]`; see String#[].
420
399
  #
421
400
  alias slice []
422
401
 
423
402
  # <!--
424
403
  # rdoc-file=string.c
425
- # - sym.start_with?([prefixes]+) -> true or false
404
+ # - start_with?(*string_or_regexp) -> true or false
426
405
  # -->
427
- # Returns true if `sym` starts with one of the `prefixes` given. Each of the
428
- # `prefixes` should be a String or a Regexp.
429
- #
430
- # :hello.start_with?("hell") #=> true
431
- # :hello.start_with?(/H/i) #=> true
432
- #
433
- # # returns true if one of the prefixes matches.
434
- # :hello.start_with?("heaven", "hell") #=> true
435
- # :hello.start_with?("heaven", "paradise") #=> false
406
+ # Equivalent to `self.to_s.start_with?`; see String#start_with?.
436
407
  #
437
408
  def start_with?: (*string | Regexp prefixes) -> bool
438
409
 
439
410
  # <!--
440
411
  # rdoc-file=string.c
441
- # - sym.succ
412
+ # - succ
442
413
  # -->
443
- # Same as `sym.to_s.succ.intern`.
414
+ # Equivalent to `self.to_s.succ.to_sym`:
415
+ #
416
+ # :foo.succ # => :fop
417
+ #
418
+ # Symbol#next is an alias for Symbol#succ.
419
+ #
420
+ # Related: String#succ.
444
421
  #
445
422
  alias succ next
446
423
 
@@ -459,32 +436,41 @@ class Symbol
459
436
 
460
437
  # <!--
461
438
  # rdoc-file=string.c
462
- # - sym.to_proc
439
+ # - to_proc
463
440
  # -->
464
- # Returns a *Proc* object which responds to the given method by *sym*.
441
+ # Returns a Proc object which calls the method with name of `self` on the first
442
+ # parameter and passes the remaining parameters to the method.
465
443
  #
466
- # (1..3).collect(&:to_s) #=> ["1", "2", "3"]
444
+ # proc = :to_s.to_proc # => #<Proc:0x000001afe0e48680(&:to_s) (lambda)>
445
+ # proc.call(1000) # => "1000"
446
+ # proc.call(1000, 16) # => "3e8"
447
+ # (1..3).collect(&:to_s) # => ["1", "2", "3"]
467
448
  #
468
449
  def to_proc: () -> Proc
469
450
 
470
451
  # <!--
471
452
  # rdoc-file=string.c
472
- # - sym.id2name -> string
473
- # - sym.to_s -> string
453
+ # - to_s -> string
474
454
  # -->
475
- # Returns the name or string corresponding to *sym*.
455
+ # Returns a string representation of `self` (not including the leading colon):
476
456
  #
477
- # :fred.id2name #=> "fred"
478
- # :ginger.to_s #=> "ginger"
457
+ # :foo.to_s # => "foo"
479
458
  #
480
- # Note that this string is not frozen (unlike the symbol itself). To get a
481
- # frozen string, use #name.
459
+ # Symbol#id2name is an alias for Symbol#to_s.
460
+ #
461
+ # Related: Symbol#inspect, Symbol#name.
482
462
  #
483
463
  alias to_s id2name
484
464
 
485
- # <!-- rdoc-file=string.c -->
486
- # In general, `to_sym` returns the Symbol corresponding to an object. As *sym*
487
- # is already a symbol, `self` is returned in this case.
465
+ # <!--
466
+ # rdoc-file=symbol.rb
467
+ # - to_sym -> self
468
+ # -->
469
+ # Returns `self`.
470
+ #
471
+ # Symbol#intern is an alias for Symbol#to_sym.
472
+ #
473
+ # Related: String#to_sym.
488
474
  #
489
475
  alias to_sym intern
490
476