@@ -131,9 +131,7 @@ class Symbol
131
131
# Symbol.all_symbols.size # => 9334
132
132
# Symbol.all_symbols.take(3) # => [:!, :"\"", :"#"]
133
133
#
134
- def self.all_symbols : () -> ::Array[Symbol]
135
-
136
- public
134
+ def self.all_symbols : () -> Array[Symbol]
137
135
138
136
# <!--
139
137
# rdoc-file=string.c
@@ -152,21 +150,21 @@ class Symbol
152
150
#
153
151
# Related: String#<=>.
154
152
#
155
- def <=> : (Symbol other ) -> Integer
156
- | (untyped other ) -> Integer?
153
+ def <=> : (Symbol object ) -> (-1 | 0 | 1)
154
+ | (untyped ) -> nil
157
155
158
156
# <!--
159
157
# rdoc-file=string.c
160
158
# - symbol == object -> true or false
161
159
# -->
162
160
# Returns `true` if `object` is the same object as `self`, `false` otherwise.
163
161
#
164
- def == : (untyped obj ) -> bool
162
+ def == : (untyped object ) -> bool
165
163
166
164
# <!-- rdoc-file=string.c -->
167
165
# Returns `true` if `object` is the same object as `self`, `false` otherwise.
168
166
#
169
- def === : ( untyped obj) -> bool
167
+ alias === ==
170
168
171
169
# <!--
172
170
# rdoc-file=string.c
@@ -176,7 +174,7 @@ class Symbol
176
174
# variables; see String#=~.
177
175
#
178
176
def =~ : (Regexp regex) -> Integer?
179
- | [T] (String::_MatchAgainst[self , T] object) -> T
177
+ | [T] (String::_MatchAgainst[T] object) -> T
180
178
181
179
# <!--
182
180
# rdoc-file=string.c
@@ -188,12 +186,10 @@ class Symbol
188
186
# -->
189
187
# Equivalent to `symbol.to_s[]`; see String#[].
190
188
#
191
- def [] : (int index) -> String?
192
- | (int start, int length) -> String?
193
- | (Range[Integer?] range) -> String?
194
- | (Regexp regexp) -> String?
195
- | (Regexp regexp, int | String capture) -> String?
196
- | (String match_str) -> String?
189
+ def [] : (int start, ?int length) -> String?
190
+ | (range[int?] range) -> String?
191
+ | (Regexp regexp, ?MatchData::capture backref) -> String?
192
+ | (String substring) -> String?
197
193
198
194
# <!--
199
195
# rdoc-file=string.c
@@ -240,7 +236,8 @@ class Symbol
240
236
#
241
237
# Related: Symbol#casecmp?, String#casecmp.
242
238
#
243
- def casecmp : (untyped other) -> Integer?
239
+ def casecmp : (Symbol object) -> (-1 | 0 | 1)?
240
+ | (untyped ) -> nil
244
241
245
242
# <!--
246
243
# rdoc-file=string.c
@@ -273,7 +270,8 @@ class Symbol
273
270
#
274
271
# Related: Symbol#casecmp, String#casecmp?.
275
272
#
276
- def casecmp? : (untyped other) -> bool ?
273
+ def casecmp? : (Symbol object) -> bool ?
274
+ | (untyped ) -> nil
277
275
278
276
# <!--
279
277
# rdoc-file=string.c
@@ -321,7 +319,7 @@ class Symbol
321
319
#
322
320
# Related: Symbol#inspect, Symbol#name.
323
321
#
324
- def id2name : () -> String
322
+ alias id2name to_s
325
323
326
324
# <!--
327
325
# rdoc-file=string.c
@@ -340,7 +338,7 @@ class Symbol
340
338
# - intern()
341
339
# -->
342
340
#
343
- def intern : () -> Symbol
341
+ alias intern to_sym
344
342
345
343
# <!--
346
344
# rdoc-file=string.c
@@ -358,16 +356,16 @@ class Symbol
358
356
# Equivalent to `self.to_s.match`, including possible updates to global
359
357
# variables; see String#match.
360
358
#
361
- def match : (Regexp | string pattern, ?int pos ) -> MatchData?
362
- | (Regexp | string pattern, ?int pos ) { (MatchData) -> void } -> untyped
359
+ def match : (Regexp | string pattern, ?int offset ) -> MatchData?
360
+ | [T] (Regexp | string pattern, ?int offset ) { (MatchData matchdata ) -> T } -> T?
363
361
364
362
# <!--
365
363
# rdoc-file=string.c
366
364
# - match?(pattern, offset) -> true or false
367
365
# -->
368
366
# Equivalent to `sym.to_s.match?`; see String#match.
369
367
#
370
- def match? : (Regexp | string pattern, ?int pos ) -> bool
368
+ def match? : (Regexp | string pattern, ?int offset ) -> bool
371
369
372
370
# <!-- rdoc-file=string.c -->
373
371
# Equivalent to `self.to_s.succ.to_sym`:
@@ -378,6 +376,20 @@ class Symbol
378
376
#
379
377
def next : () -> Symbol
380
378
379
+ # <!--
380
+ # rdoc-file=string.c
381
+ # - name -> string
382
+ # -->
383
+ # Returns a frozen string representation of `self` (not including the leading
384
+ # colon):
385
+ #
386
+ # :foo.name # => "foo"
387
+ # :foo.name.frozen? # => true
388
+ #
389
+ # Related: Symbol#to_s, Symbol#inspect.
390
+ #
391
+ def name : () -> String
392
+
381
393
# <!-- rdoc-file=string.c -->
382
394
# Equivalent to `self.to_s.length`; see String#length.
383
395
#
@@ -394,7 +406,7 @@ class Symbol
394
406
# -->
395
407
# Equivalent to `self.to_s.start_with?`; see String#start_with?.
396
408
#
397
- def start_with? : (*string | Regexp prefixes) -> bool
409
+ def start_with? : (*Regexp | string prefixes) -> bool
398
410
399
411
# <!--
400
412
# rdoc-file=string.c
@@ -445,7 +457,7 @@ class Symbol
445
457
#
446
458
# Related: Symbol#inspect, Symbol#name.
447
459
#
448
- alias to_s id2name
460
+ def to_s : () -> String
449
461
450
462
# <!--
451
463
# rdoc-file=symbol.rb
@@ -455,7 +467,7 @@ class Symbol
455
467
#
456
468
# Related: String#to_sym.
457
469
#
458
- alias to_sym intern
470
+ def to_sym : () -> self
459
471
460
472
# <!--
461
473
# rdoc-file=string.c
@@ -469,6 +481,4 @@ class Symbol
469
481
| (:ascii | :lithuanian | :turkic) -> Symbol
470
482
| (:lithuanian, :turkic) -> Symbol
471
483
| (:turkic, :lithuanian) -> Symbol
472
-
473
- def clone : (?freeze: true?) -> self
474
484
end
0 commit comments