rbs 3.0.0.dev.2 → 3.0.0.dev.3
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/.github/workflows/comments.yml +2 -1
- data/.github/workflows/ruby.yml +4 -0
- data/Gemfile.lock +11 -11
- data/Rakefile +2 -2
- data/Steepfile +1 -1
- data/core/array.rbs +573 -423
- data/core/basic_object.rbs +11 -39
- data/core/binding.rbs +1 -1
- data/core/builtin.rbs +8 -0
- data/core/class.rbs +37 -0
- data/core/comparable.rbs +7 -18
- data/core/complex.rbs +2 -2
- data/core/data.rbs +419 -0
- data/core/dir.rbs +52 -104
- data/core/encoding.rbs +22 -181
- data/core/enumerable.rbs +212 -175
- data/core/enumerator/product.rbs +96 -0
- data/core/enumerator.rbs +57 -8
- data/core/errors.rbs +8 -2
- data/core/exception.rbs +41 -0
- data/core/fiber.rbs +95 -12
- data/core/file.rbs +840 -275
- data/core/file_test.rbs +34 -19
- data/core/float.rbs +40 -96
- data/core/gc.rbs +15 -3
- data/core/hash.rbs +113 -175
- data/core/integer.rbs +85 -145
- data/core/io/buffer.rbs +187 -60
- data/core/io/wait.rbs +28 -16
- data/core/io.rbs +1859 -1389
- data/core/kernel.rbs +525 -961
- data/core/match_data.rbs +306 -142
- data/core/math.rbs +506 -234
- data/core/method.rbs +0 -24
- data/core/module.rbs +110 -17
- data/core/nil_class.rbs +2 -0
- data/core/numeric.rbs +76 -144
- data/core/object.rbs +88 -212
- data/core/proc.rbs +17 -5
- data/core/process.rbs +22 -5
- data/core/ractor.rbs +1 -1
- data/core/random.rbs +20 -3
- data/core/range.rbs +91 -89
- data/core/rational.rbs +2 -3
- data/core/rbs/unnamed/argf.rbs +177 -120
- data/core/rbs/unnamed/env_class.rbs +89 -163
- data/core/rbs/unnamed/random.rbs +36 -12
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +462 -272
- data/core/ruby_vm.rbs +210 -0
- data/{stdlib/set/0 → core}/set.rbs +43 -47
- data/core/string.rbs +1403 -1332
- data/core/string_io.rbs +191 -107
- data/core/struct.rbs +67 -63
- data/core/symbol.rbs +187 -201
- data/core/thread.rbs +40 -35
- data/core/time.rbs +902 -826
- data/core/trace_point.rbs +55 -6
- data/core/unbound_method.rbs +48 -24
- data/docs/collection.md +4 -0
- data/docs/syntax.md +55 -0
- data/ext/rbs_extension/parser.c +5 -6
- data/lib/rbs/cli.rb +6 -1
- data/lib/rbs/collection/cleaner.rb +8 -1
- data/lib/rbs/collection/config/lockfile.rb +3 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
- data/lib/rbs/collection/config.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +9 -2
- data/lib/rbs/collection/sources/local.rb +79 -0
- data/lib/rbs/collection/sources.rb +8 -1
- data/lib/rbs/environment.rb +6 -5
- data/lib/rbs/environment_loader.rb +3 -2
- data/lib/rbs/errors.rb +18 -0
- data/lib/rbs/locator.rb +26 -7
- data/lib/rbs/sorter.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/sig/collection/sources.rbs +32 -3
- data/sig/environment.rbs +2 -3
- data/sig/locator.rbs +14 -2
- data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
- data/stdlib/cgi/0/core.rbs +16 -0
- data/stdlib/coverage/0/coverage.rbs +50 -8
- data/stdlib/csv/0/csv.rbs +1 -1
- data/stdlib/date/0/date.rbs +856 -726
- data/stdlib/date/0/date_time.rbs +83 -210
- data/stdlib/erb/0/erb.rbs +13 -36
- data/stdlib/etc/0/etc.rbs +127 -20
- data/stdlib/fileutils/0/fileutils.rbs +1290 -381
- data/stdlib/logger/0/logger.rbs +466 -316
- data/stdlib/net-http/0/net-http.rbs +2211 -534
- data/stdlib/nkf/0/nkf.rbs +5 -5
- data/stdlib/objspace/0/objspace.rbs +31 -14
- data/stdlib/openssl/0/openssl.rbs +11 -7
- data/stdlib/optparse/0/optparse.rbs +20 -17
- data/stdlib/pathname/0/pathname.rbs +21 -4
- data/stdlib/pstore/0/pstore.rbs +378 -154
- data/stdlib/pty/0/pty.rbs +24 -8
- data/stdlib/ripper/0/ripper.rbs +1650 -0
- data/stdlib/socket/0/addrinfo.rbs +9 -15
- data/stdlib/socket/0/socket.rbs +36 -3
- data/stdlib/strscan/0/string_scanner.rbs +7 -5
- data/stdlib/tempfile/0/tempfile.rbs +104 -44
- data/stdlib/time/0/time.rbs +2 -2
- data/stdlib/uri/0/file.rbs +5 -0
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/yaml/0/yaml.rbs +2 -2
- data/stdlib/zlib/0/zlib.rbs +1 -1
- metadata +8 -6
- data/core/deprecated.rbs +0 -9
- 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](
|
|
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
|
-
#
|
|
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](
|
|
71
|
-
# * [Comparing](
|
|
72
|
-
# * [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
|
-
#
|
|
78
|
-
#
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
#
|
|
84
|
-
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
-
#
|
|
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
|
-
#
|
|
115
|
-
#
|
|
116
|
-
#
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
#
|
|
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
|
-
#
|
|
134
|
-
#
|
|
135
|
-
#
|
|
136
|
-
#
|
|
137
|
-
#
|
|
138
|
-
# :
|
|
139
|
-
#
|
|
140
|
-
#
|
|
141
|
-
# :
|
|
142
|
-
#
|
|
143
|
-
#
|
|
144
|
-
# :
|
|
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
|
|
127
|
+
# - Symbol.all_symbols -> array_of_symbols
|
|
171
128
|
# -->
|
|
172
|
-
# Returns an array of all
|
|
129
|
+
# Returns an array of all symbols currently in Ruby's symbol table:
|
|
173
130
|
#
|
|
174
|
-
# Symbol.all_symbols.size
|
|
175
|
-
# Symbol.all_symbols
|
|
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 <=>
|
|
140
|
+
# - symbol <=> object -> -1, 0, +1, or nil
|
|
189
141
|
# -->
|
|
190
|
-
#
|
|
191
|
-
#
|
|
192
|
-
#
|
|
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
|
-
#
|
|
151
|
+
# :foo <=> 'bar' # => nil
|
|
195
152
|
#
|
|
196
|
-
#
|
|
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
|
-
# -
|
|
160
|
+
# - symbol == object -> true or false
|
|
204
161
|
# -->
|
|
205
|
-
#
|
|
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
|
-
#
|
|
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
|
-
# -
|
|
177
|
+
# - symbol =~ object -> integer or nil
|
|
217
178
|
# -->
|
|
218
|
-
#
|
|
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
|
-
# -
|
|
225
|
-
# -
|
|
226
|
-
# -
|
|
227
|
-
# -
|
|
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
|
-
#
|
|
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(
|
|
216
|
+
# - casecmp(object) -> -1, 0, 1, or nil
|
|
254
217
|
# -->
|
|
255
|
-
#
|
|
218
|
+
# Like Symbol#<=>, but case-insensitive; equivalent to
|
|
219
|
+
# `self.to_s.casecmp(object.to_s)`:
|
|
256
220
|
#
|
|
257
|
-
#
|
|
258
|
-
#
|
|
259
|
-
#
|
|
260
|
-
#
|
|
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
|
|
263
|
-
#
|
|
227
|
+
# Returns nil if `self` and `object` have incompatible encodings, or if `object`
|
|
228
|
+
# is not a symbol:
|
|
264
229
|
#
|
|
265
|
-
# sym =
|
|
266
|
-
# other_sym =
|
|
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
|
-
#
|
|
271
|
-
#
|
|
235
|
+
# Unlike Symbol#casecmp?, case-insensitivity does not work for characters
|
|
236
|
+
# outside of 'A'..'Z' and 'a'..'z':
|
|
272
237
|
#
|
|
273
|
-
#
|
|
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?(
|
|
250
|
+
# - casecmp?(object) -> true, false, or nil
|
|
280
251
|
# -->
|
|
281
|
-
# Returns `true` if `
|
|
282
|
-
#
|
|
252
|
+
# Returns `true` if `self` and `object` are equal after Unicode case folding,
|
|
253
|
+
# otherwise `false`:
|
|
283
254
|
#
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
#
|
|
287
|
-
#
|
|
288
|
-
#
|
|
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
|
|
291
|
-
#
|
|
261
|
+
# Returns nil if `self` and `object` have incompatible encodings, or if `object`
|
|
262
|
+
# is not a symbol:
|
|
292
263
|
#
|
|
293
|
-
# sym =
|
|
294
|
-
# other_sym =
|
|
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
|
-
#
|
|
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
|
-
# -
|
|
298
|
+
# - empty? -> true or false
|
|
322
299
|
# -->
|
|
323
|
-
# Returns
|
|
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
|
-
# -
|
|
306
|
+
# - encoding -> encoding
|
|
330
307
|
# -->
|
|
331
|
-
#
|
|
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
|
-
# -
|
|
314
|
+
# - end_with?(*string_or_regexp) -> true or false
|
|
338
315
|
# -->
|
|
339
|
-
#
|
|
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
|
|
321
|
+
# Returns a string representation of `self` (not including the leading colon):
|
|
322
|
+
#
|
|
323
|
+
# :foo.to_s # => "foo"
|
|
351
324
|
#
|
|
352
|
-
#
|
|
353
|
-
# :ginger.to_s #=> "ginger"
|
|
325
|
+
# Symbol#id2name is an alias for Symbol#to_s.
|
|
354
326
|
#
|
|
355
|
-
#
|
|
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
|
-
# -
|
|
333
|
+
# - inspect -> string
|
|
363
334
|
# -->
|
|
364
|
-
# Returns
|
|
335
|
+
# Returns a string representation of `self` (including the leading colon):
|
|
365
336
|
#
|
|
366
|
-
# :
|
|
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=
|
|
372
|
-
# -
|
|
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
|
-
# -
|
|
383
|
-
# - sym.size -> integer
|
|
352
|
+
# - length -> integer
|
|
384
353
|
# -->
|
|
385
|
-
#
|
|
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
|
-
# -
|
|
392
|
-
# -
|
|
362
|
+
# - match(pattern, offset = 0) -> matchdata or nil
|
|
363
|
+
# - match(pattern, offset = 0) {|matchdata| } -> object
|
|
393
364
|
# -->
|
|
394
|
-
#
|
|
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
|
-
# -
|
|
402
|
-
# - sym.match?(pattern, pos) -> true or false
|
|
373
|
+
# - match?(pattern, offset) -> true or false
|
|
403
374
|
# -->
|
|
404
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
# -
|
|
404
|
+
# - start_with?(*string_or_regexp) -> true or false
|
|
426
405
|
# -->
|
|
427
|
-
#
|
|
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
|
-
# -
|
|
412
|
+
# - succ
|
|
442
413
|
# -->
|
|
443
|
-
#
|
|
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
|
-
# -
|
|
439
|
+
# - to_proc
|
|
463
440
|
# -->
|
|
464
|
-
# Returns a
|
|
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
|
-
#
|
|
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
|
-
# -
|
|
473
|
-
# - sym.to_s -> string
|
|
453
|
+
# - to_s -> string
|
|
474
454
|
# -->
|
|
475
|
-
# Returns
|
|
455
|
+
# Returns a string representation of `self` (not including the leading colon):
|
|
476
456
|
#
|
|
477
|
-
# :
|
|
478
|
-
# :ginger.to_s #=> "ginger"
|
|
457
|
+
# :foo.to_s # => "foo"
|
|
479
458
|
#
|
|
480
|
-
#
|
|
481
|
-
#
|
|
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
|
-
# <!--
|
|
486
|
-
#
|
|
487
|
-
#
|
|
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
|
|