steep 0.16.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -3
- data/CHANGELOG.md +6 -0
- data/Rakefile +0 -13
- data/bin/setup +0 -2
- data/bin/smoke_runner.rb +0 -1
- data/exe/steep +0 -1
- data/lib/steep/project/file.rb +1 -1
- data/lib/steep/project/hover_content.rb +1 -1
- data/lib/steep/server/code_worker.rb +1 -1
- data/lib/steep/server/signature_worker.rb +4 -4
- data/lib/steep/type_construction.rb +10 -16
- data/lib/steep/type_inference/constant_env.rb +2 -10
- data/lib/steep/type_inference/context.rb +1 -0
- data/lib/steep/version.rb +1 -1
- data/steep.gemspec +1 -5
- metadata +17 -135
- data/exe/rbs +0 -3
- data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
- data/vendor/ruby-signature/.gitignore +0 -12
- data/vendor/ruby-signature/.rubocop.yml +0 -15
- data/vendor/ruby-signature/BSDL +0 -22
- data/vendor/ruby-signature/COPYING +0 -56
- data/vendor/ruby-signature/Gemfile +0 -6
- data/vendor/ruby-signature/README.md +0 -93
- data/vendor/ruby-signature/Rakefile +0 -142
- data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -157
- data/vendor/ruby-signature/bin/console +0 -14
- data/vendor/ruby-signature/bin/query-rdoc +0 -103
- data/vendor/ruby-signature/bin/setup +0 -10
- data/vendor/ruby-signature/bin/sort +0 -89
- data/vendor/ruby-signature/bin/test_runner.rb +0 -16
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
- data/vendor/ruby-signature/docs/sigs.md +0 -148
- data/vendor/ruby-signature/docs/stdlib.md +0 -152
- data/vendor/ruby-signature/docs/syntax.md +0 -528
- data/vendor/ruby-signature/exe/rbs +0 -7
- data/vendor/ruby-signature/lib/rbs.rb +0 -64
- data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +0 -27
- data/vendor/ruby-signature/lib/rbs/ast/comment.rb +0 -27
- data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +0 -395
- data/vendor/ruby-signature/lib/rbs/ast/members.rb +0 -362
- data/vendor/ruby-signature/lib/rbs/buffer.rb +0 -50
- data/vendor/ruby-signature/lib/rbs/builtin_names.rb +0 -55
- data/vendor/ruby-signature/lib/rbs/cli.rb +0 -558
- data/vendor/ruby-signature/lib/rbs/constant.rb +0 -26
- data/vendor/ruby-signature/lib/rbs/constant_table.rb +0 -150
- data/vendor/ruby-signature/lib/rbs/definition.rb +0 -170
- data/vendor/ruby-signature/lib/rbs/definition_builder.rb +0 -919
- data/vendor/ruby-signature/lib/rbs/environment.rb +0 -281
- data/vendor/ruby-signature/lib/rbs/environment_loader.rb +0 -136
- data/vendor/ruby-signature/lib/rbs/environment_walker.rb +0 -124
- data/vendor/ruby-signature/lib/rbs/errors.rb +0 -187
- data/vendor/ruby-signature/lib/rbs/location.rb +0 -102
- data/vendor/ruby-signature/lib/rbs/method_type.rb +0 -123
- data/vendor/ruby-signature/lib/rbs/namespace.rb +0 -91
- data/vendor/ruby-signature/lib/rbs/parser.y +0 -1344
- data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +0 -553
- data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +0 -587
- data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +0 -381
- data/vendor/ruby-signature/lib/rbs/substitution.rb +0 -46
- data/vendor/ruby-signature/lib/rbs/test.rb +0 -26
- data/vendor/ruby-signature/lib/rbs/test/errors.rb +0 -61
- data/vendor/ruby-signature/lib/rbs/test/hook.rb +0 -294
- data/vendor/ruby-signature/lib/rbs/test/setup.rb +0 -58
- data/vendor/ruby-signature/lib/rbs/test/spy.rb +0 -325
- data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +0 -183
- data/vendor/ruby-signature/lib/rbs/test/type_check.rb +0 -254
- data/vendor/ruby-signature/lib/rbs/type_name.rb +0 -70
- data/vendor/ruby-signature/lib/rbs/types.rb +0 -936
- data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +0 -138
- data/vendor/ruby-signature/lib/rbs/vendorer.rb +0 -47
- data/vendor/ruby-signature/lib/rbs/version.rb +0 -3
- data/vendor/ruby-signature/lib/rbs/writer.rb +0 -269
- data/vendor/ruby-signature/lib/ruby/signature.rb +0 -7
- data/vendor/ruby-signature/rbs.gemspec +0 -46
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -60
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -71
- data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +0 -372
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -45
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -413
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -607
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -194
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -1076
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -243
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -707
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -576
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -161
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -271
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -369
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -185
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -1104
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -429
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -1227
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -267
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -57
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -1083
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -1901
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -284
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -228
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1108
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -1047
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -290
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -153
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
- data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +0 -62
- data/vendor/ruby-signature/stdlib/csv/csv.rbs +0 -773
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -392
- data/vendor/ruby-signature/stdlib/find/find.rbs +0 -40
- data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +0 -247
- data/vendor/ruby-signature/stdlib/json/json.rbs +0 -335
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -1093
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
- data/vendor/ruby-signature/stdlib/set/set.rbs +0 -301
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,284 +0,0 @@
|
|
1
|
-
# Pseudo I/O on String object, with interface corresponding to IO.
|
2
|
-
#
|
3
|
-
# Commonly used to simulate `$stdio` or `$stderr`
|
4
|
-
#
|
5
|
-
# ### Examples
|
6
|
-
#
|
7
|
-
# require 'stringio'
|
8
|
-
#
|
9
|
-
# # Writing stream emulation
|
10
|
-
# io = StringIO.new
|
11
|
-
# io.puts "Hello World"
|
12
|
-
# io.string #=> "Hello World\n"
|
13
|
-
#
|
14
|
-
# # Reading stream emulation
|
15
|
-
# io = StringIO.new "first\nsecond\nlast\n"
|
16
|
-
# io.getc #=> "f"
|
17
|
-
# io.gets #=> "irst\n"
|
18
|
-
# io.read #=> "second\nlast\n"
|
19
|
-
#
|
20
|
-
class StringIO
|
21
|
-
# Creates new StringIO instance from with *string* and *mode*.
|
22
|
-
#
|
23
|
-
def initialize: (?String string, ?String? mode) -> void
|
24
|
-
|
25
|
-
# Equivalent to StringIO.new except that when it is called with a block, it
|
26
|
-
# yields with the new instance and closes it, and returns the result which
|
27
|
-
# returned from the block.
|
28
|
-
#
|
29
|
-
def self.open: [U] (?String string, ?String? mode) { (StringIO arg) -> U } -> U
|
30
|
-
|
31
|
-
def <<: (untyped arg0) -> self
|
32
|
-
|
33
|
-
# Puts stream into binary mode. See IO#binmode.
|
34
|
-
#
|
35
|
-
def binmode: () -> self
|
36
|
-
|
37
|
-
# Closes a StringIO. The stream is unavailable for any further data operations;
|
38
|
-
# an `IOError` is raised if such an attempt is made.
|
39
|
-
#
|
40
|
-
def close: () -> nil
|
41
|
-
|
42
|
-
# Closes the read end of a StringIO. Will raise an `IOError` if the receiver is
|
43
|
-
# not readable.
|
44
|
-
#
|
45
|
-
def close_read: () -> nil
|
46
|
-
|
47
|
-
# Closes the write end of a StringIO. Will raise an `IOError` if the receiver
|
48
|
-
# is not writeable.
|
49
|
-
#
|
50
|
-
def close_write: () -> nil
|
51
|
-
|
52
|
-
# Returns `true` if the stream is completely closed, `false` otherwise.
|
53
|
-
#
|
54
|
-
def closed?: () -> bool
|
55
|
-
|
56
|
-
# Returns `true` if the stream is not readable, `false` otherwise.
|
57
|
-
#
|
58
|
-
def closed_read?: () -> bool
|
59
|
-
|
60
|
-
# Returns `true` if the stream is not writable, `false` otherwise.
|
61
|
-
#
|
62
|
-
def closed_write?: () -> bool
|
63
|
-
|
64
|
-
# See IO#each.
|
65
|
-
#
|
66
|
-
def each: (?String sep, ?Integer limit, ?chomp: bool) { (String arg0) -> untyped } -> self
|
67
|
-
| (?String sep, ?Integer limit, ?chomp: bool) -> ::Enumerator[String, self]
|
68
|
-
|
69
|
-
# See IO#each_byte.
|
70
|
-
#
|
71
|
-
def each_byte: () { (Integer arg0) -> untyped } -> self
|
72
|
-
| () -> ::Enumerator[Integer, self]
|
73
|
-
|
74
|
-
# See IO#each_char.
|
75
|
-
#
|
76
|
-
def each_char: () { (String arg0) -> untyped } -> self
|
77
|
-
| () -> ::Enumerator[String, self]
|
78
|
-
|
79
|
-
# See IO#each_codepoint.
|
80
|
-
#
|
81
|
-
def each_codepoint: () { (Integer arg0) -> untyped } -> self
|
82
|
-
| () -> ::Enumerator[Integer, self]
|
83
|
-
|
84
|
-
# Returns true if the stream is at the end of the data (underlying string). The
|
85
|
-
# stream must be opened for reading or an `IOError` will be raised.
|
86
|
-
#
|
87
|
-
def eof: () -> bool
|
88
|
-
|
89
|
-
# Raises NotImplementedError.
|
90
|
-
#
|
91
|
-
def fcntl: (Integer integer_cmd, String | Integer arg) -> Integer
|
92
|
-
|
93
|
-
# Returns `nil`. Just for compatibility to IO.
|
94
|
-
#
|
95
|
-
def fileno: () -> nil
|
96
|
-
|
97
|
-
# Returns an object itself. Just for compatibility to IO.
|
98
|
-
#
|
99
|
-
def flush: () -> self
|
100
|
-
|
101
|
-
# Returns 0. Just for compatibility to IO.
|
102
|
-
#
|
103
|
-
def fsync: () -> Integer?
|
104
|
-
|
105
|
-
# See IO#getbyte.
|
106
|
-
#
|
107
|
-
def getbyte: () -> Integer?
|
108
|
-
|
109
|
-
# See IO#getc.
|
110
|
-
#
|
111
|
-
def getc: () -> String?
|
112
|
-
|
113
|
-
# See IO#gets.
|
114
|
-
#
|
115
|
-
def gets: (?String sep, ?Integer limit, ?chomp: bool) -> String?
|
116
|
-
|
117
|
-
# Returns the Encoding of the internal string if conversion is specified.
|
118
|
-
# Otherwise returns `nil`.
|
119
|
-
#
|
120
|
-
def internal_encoding: () -> Encoding
|
121
|
-
|
122
|
-
# Returns the Encoding object that represents the encoding of the file. If the
|
123
|
-
# stream is write mode and no encoding is specified, returns `nil`.
|
124
|
-
#
|
125
|
-
def external_encoding: () -> Encoding
|
126
|
-
|
127
|
-
# Returns `false`. Just for compatibility to IO.
|
128
|
-
#
|
129
|
-
def isatty: () -> bool
|
130
|
-
|
131
|
-
# Returns the current line number. The stream must be opened for reading.
|
132
|
-
# `lineno` counts the number of times `gets` is called, rather than the number
|
133
|
-
# of newlines encountered. The two values will differ if `gets` is called with
|
134
|
-
# a separator other than newline. See also the `$.` variable.
|
135
|
-
#
|
136
|
-
def lineno: () -> Integer
|
137
|
-
|
138
|
-
# Manually sets the current line number to the given value. `$.` is updated only
|
139
|
-
# on the next read.
|
140
|
-
#
|
141
|
-
def lineno=: (Integer arg0) -> Integer
|
142
|
-
|
143
|
-
# Returns `nil`. Just for compatibility to IO.
|
144
|
-
#
|
145
|
-
def pid: () -> nil
|
146
|
-
|
147
|
-
# Returns the current offset (in bytes).
|
148
|
-
#
|
149
|
-
def pos: () -> Integer
|
150
|
-
|
151
|
-
# Seeks to the given position (in bytes).
|
152
|
-
#
|
153
|
-
def pos=: (Integer arg0) -> Integer
|
154
|
-
|
155
|
-
def print: (*untyped arg0) -> nil
|
156
|
-
|
157
|
-
def printf: (String format_string, *untyped arg0) -> nil
|
158
|
-
|
159
|
-
# See IO#putc.
|
160
|
-
#
|
161
|
-
def putc: (Numeric | String arg0) -> untyped
|
162
|
-
|
163
|
-
def puts: (*untyped arg0) -> nil
|
164
|
-
|
165
|
-
# See IO#read.
|
166
|
-
#
|
167
|
-
def read: (?Integer length, ?String outbuf) -> String?
|
168
|
-
|
169
|
-
def read_nonblock: (Integer len) -> String
|
170
|
-
| (Integer len, ?String buf) -> String
|
171
|
-
|
172
|
-
def readbyte: () -> Integer
|
173
|
-
|
174
|
-
def readchar: () -> String
|
175
|
-
|
176
|
-
def readline: (?String sep, ?Integer limit) -> String
|
177
|
-
|
178
|
-
# See IO#readlines.
|
179
|
-
#
|
180
|
-
def readlines: (?String sep, ?Integer limit, ?chomp: bool) -> ::Array[String]
|
181
|
-
|
182
|
-
def readpartial: (Integer maxlen) -> String
|
183
|
-
| (Integer maxlen, ?String outbuf) -> String
|
184
|
-
|
185
|
-
# Reinitializes the stream with the given *other_StrIO* or *string* and *mode*
|
186
|
-
# (see StringIO#new).
|
187
|
-
#
|
188
|
-
def reopen: (StringIO other) -> self
|
189
|
-
| (String other, ?String mode_str) -> self
|
190
|
-
|
191
|
-
# Positions the stream to the beginning of input, resetting `lineno` to zero.
|
192
|
-
#
|
193
|
-
def rewind: () -> Integer
|
194
|
-
|
195
|
-
# Seeks to a given offset *amount* in the stream according to the value of
|
196
|
-
# *whence* (see IO#seek).
|
197
|
-
#
|
198
|
-
def seek: (Integer amount, ?Integer whence) -> Integer
|
199
|
-
|
200
|
-
# Specify the encoding of the StringIO as *ext_enc*. Use the default external
|
201
|
-
# encoding if *ext_enc* is nil. 2nd argument *int_enc* and optional hash *opt*
|
202
|
-
# argument are ignored; they are for API compatibility to IO.
|
203
|
-
#
|
204
|
-
def set_encoding: (?String | Encoding ext_or_ext_int_enc) -> self
|
205
|
-
| (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self
|
206
|
-
|
207
|
-
# Returns underlying String object, the subject of IO.
|
208
|
-
#
|
209
|
-
def string: () -> String
|
210
|
-
|
211
|
-
# Changes underlying String object, the subject of IO.
|
212
|
-
#
|
213
|
-
def string=: (String str) -> String
|
214
|
-
|
215
|
-
# Returns the size of the buffer string.
|
216
|
-
#
|
217
|
-
def size: () -> Integer
|
218
|
-
|
219
|
-
# Returns `true` always.
|
220
|
-
#
|
221
|
-
def sync: () -> bool
|
222
|
-
|
223
|
-
# Returns the argument unchanged. Just for compatibility to IO.
|
224
|
-
#
|
225
|
-
def sync=: (bool arg0) -> bool
|
226
|
-
|
227
|
-
def sysread: (Integer maxlen, String outbuf) -> String
|
228
|
-
|
229
|
-
def syswrite: (String arg0) -> Integer
|
230
|
-
|
231
|
-
# Returns the current offset (in bytes).
|
232
|
-
#
|
233
|
-
def tell: () -> Integer
|
234
|
-
|
235
|
-
# Returns `false`. Just for compatibility to IO.
|
236
|
-
#
|
237
|
-
def tty?: () -> bool
|
238
|
-
|
239
|
-
# See IO#ungetbyte
|
240
|
-
#
|
241
|
-
def ungetbyte: (String | Integer arg0) -> nil
|
242
|
-
|
243
|
-
# Pushes back one character (passed as a parameter) such that a subsequent
|
244
|
-
# buffered read will return it. There is no limitation for multiple pushbacks
|
245
|
-
# including pushing back behind the beginning of the buffer string.
|
246
|
-
#
|
247
|
-
def ungetc: (String arg0) -> nil
|
248
|
-
|
249
|
-
# Appends the given string to the underlying buffer string. The stream must be
|
250
|
-
# opened for writing. If the argument is not a string, it will be converted to
|
251
|
-
# a string using `to_s`. Returns the number of bytes written. See IO#write.
|
252
|
-
#
|
253
|
-
def write: (String arg0) -> Integer
|
254
|
-
|
255
|
-
# This is a deprecated alias for #each_byte.
|
256
|
-
#
|
257
|
-
def bytes: () { (Integer arg0) -> untyped } -> self
|
258
|
-
| () -> ::Enumerator[Integer, self]
|
259
|
-
|
260
|
-
# This is a deprecated alias for #each_char.
|
261
|
-
#
|
262
|
-
def chars: () { (String arg0) -> untyped } -> self
|
263
|
-
| () -> ::Enumerator[String, self]
|
264
|
-
|
265
|
-
# This is a deprecated alias for #each_codepoint.
|
266
|
-
#
|
267
|
-
def codepoints: () { (Integer arg0) -> untyped } -> self
|
268
|
-
| () -> ::Enumerator[Integer, self]
|
269
|
-
|
270
|
-
# See IO#each.
|
271
|
-
#
|
272
|
-
def each_line: (?String sep, ?Integer limit, ?chomp: bool) { (String arg0) -> untyped } -> self
|
273
|
-
| (?String sep, ?Integer limit, ?chomp: bool) -> ::Enumerator[String, self]
|
274
|
-
|
275
|
-
# Returns true if the stream is at the end of the data (underlying string). The
|
276
|
-
# stream must be opened for reading or an `IOError` will be raised.
|
277
|
-
#
|
278
|
-
def eof?: () -> bool
|
279
|
-
|
280
|
-
# This is a deprecated alias for #each_line.
|
281
|
-
#
|
282
|
-
def lines: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self
|
283
|
-
| (?String sep, ?Integer limit) -> ::Enumerator[String, self]
|
284
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# A [Struct](Struct) is a convenient way to bundle a
|
2
|
-
# number of attributes together, using accessor methods, without having to
|
3
|
-
# write an explicit class.
|
4
|
-
#
|
5
|
-
# The [Struct](Struct) class generates new subclasses
|
6
|
-
# that hold a set of members and their values. For each member a reader
|
7
|
-
# and writer method is created similar to
|
8
|
-
# [Module\#attr\_accessor](https://ruby-doc.org/core-2.6.3/Module.html#method-i-attr_accessor)
|
9
|
-
# .
|
10
|
-
#
|
11
|
-
# ```ruby
|
12
|
-
# Customer = Struct.new(:name, :address) do
|
13
|
-
# def greeting
|
14
|
-
# "Hello #{name}!"
|
15
|
-
# end
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# dave = Customer.new("Dave", "123 Main")
|
19
|
-
# dave.name #=> "Dave"
|
20
|
-
# dave.greeting #=> "Hello Dave!"
|
21
|
-
# ```
|
22
|
-
#
|
23
|
-
# See [::new](Struct#method-c-new) for further
|
24
|
-
# examples of creating struct subclasses and instances.
|
25
|
-
#
|
26
|
-
# In the method descriptions that follow, a "member" parameter refers to a
|
27
|
-
# struct member which is either a quoted string ( `"name"` ) or a
|
28
|
-
# [Symbol](https://ruby-doc.org/core-2.6.3/Symbol.html) ( `:name` ).
|
29
|
-
class Struct[Elem] < Object
|
30
|
-
include Enumerable[Elem, Struct[Elem]]
|
31
|
-
|
32
|
-
def initialize: (Symbol | String arg0, *Symbol | String arg1, ?keyword_init: bool keyword_init) -> void
|
33
|
-
|
34
|
-
def each: () { (Elem arg0) -> untyped } -> untyped
|
35
|
-
| () -> self
|
36
|
-
|
37
|
-
def self.members: () -> ::Array[Symbol]
|
38
|
-
|
39
|
-
def new: (*untyped args) -> Struct[untyped]
|
40
|
-
end
|
@@ -1,228 +0,0 @@
|
|
1
|
-
# Symbol objects represent names inside the Ruby interpreter. They are generated
|
2
|
-
# using the `:name` and `:"string"` literals syntax, and by the various `to_sym`
|
3
|
-
# methods. The same Symbol object will be created for a given name or string for
|
4
|
-
# the duration of a program's execution, regardless of the context or meaning of
|
5
|
-
# that name. Thus if `Fred` is a constant in one context, a method in another,
|
6
|
-
# and a class in a third, the Symbol `:Fred` will be the same object in all
|
7
|
-
# three contexts.
|
8
|
-
#
|
9
|
-
# module One
|
10
|
-
# class Fred
|
11
|
-
# end
|
12
|
-
# $f1 = :Fred
|
13
|
-
# end
|
14
|
-
# module Two
|
15
|
-
# Fred = 1
|
16
|
-
# $f2 = :Fred
|
17
|
-
# end
|
18
|
-
# def Fred()
|
19
|
-
# end
|
20
|
-
# $f3 = :Fred
|
21
|
-
# $f1.object_id #=> 2514190
|
22
|
-
# $f2.object_id #=> 2514190
|
23
|
-
# $f3.object_id #=> 2514190
|
24
|
-
#
|
25
|
-
class Symbol
|
26
|
-
include Comparable
|
27
|
-
|
28
|
-
# Returns an array of all the symbols currently in Ruby's symbol table.
|
29
|
-
#
|
30
|
-
# Symbol.all_symbols.size #=> 903
|
31
|
-
# Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
|
32
|
-
# :chown, :EOFError, :$;, :String,
|
33
|
-
# :LOCK_SH, :"setuid?", :$<,
|
34
|
-
# :default_proc, :compact, :extend,
|
35
|
-
# :Tms, :getwd, :$=, :ThreadGroup,
|
36
|
-
# :wait2, :$>]
|
37
|
-
#
|
38
|
-
def self.all_symbols: () -> ::Array[Symbol]
|
39
|
-
|
40
|
-
public
|
41
|
-
|
42
|
-
# Compares `symbol` with `other_symbol` after calling #to_s on each of the
|
43
|
-
# symbols. Returns -1, 0, +1, or `nil` depending on whether `symbol` is less
|
44
|
-
# than, equal to, or greater than `other_symbol`.
|
45
|
-
#
|
46
|
-
# `nil` is returned if the two values are incomparable.
|
47
|
-
#
|
48
|
-
# See String#<=> for more information.
|
49
|
-
#
|
50
|
-
def <=>: (untyped other) -> Integer?
|
51
|
-
|
52
|
-
# Equality---If *sym* and *obj* are exactly the same symbol, returns `true`.
|
53
|
-
#
|
54
|
-
def ==: (untyped obj) -> bool
|
55
|
-
|
56
|
-
# Equality---If *sym* and *obj* are exactly the same symbol, returns `true`.
|
57
|
-
#
|
58
|
-
def ===: (untyped obj) -> bool
|
59
|
-
|
60
|
-
# Returns `sym.to_s =~ obj`.
|
61
|
-
#
|
62
|
-
def =~: (untyped obj) -> Integer?
|
63
|
-
|
64
|
-
# Returns `sym.to_s[]`.
|
65
|
-
#
|
66
|
-
def []: (int index) -> String?
|
67
|
-
| (int start, int length) -> String?
|
68
|
-
| (Range[Integer?] range) -> String?
|
69
|
-
| (Regexp regexp) -> String?
|
70
|
-
| (Regexp regexp, int | String capture) -> String?
|
71
|
-
| (String match_str) -> String?
|
72
|
-
|
73
|
-
# Same as `sym.to_s.capitalize.intern`.
|
74
|
-
#
|
75
|
-
def capitalize: () -> Symbol
|
76
|
-
| (:ascii | :lithuanian | :turkic) -> Symbol
|
77
|
-
| (:lithuanian, :turkic) -> Symbol
|
78
|
-
| (:turkic, :lithuanian) -> Symbol
|
79
|
-
|
80
|
-
# Case-insensitive version of Symbol#<=>. Currently, case-insensitivity only
|
81
|
-
# works on characters A-Z/a-z, not all of Unicode. This is different from
|
82
|
-
# Symbol#casecmp?.
|
83
|
-
#
|
84
|
-
# :aBcDeF.casecmp(:abcde) #=> 1
|
85
|
-
# :aBcDeF.casecmp(:abcdef) #=> 0
|
86
|
-
# :aBcDeF.casecmp(:abcdefg) #=> -1
|
87
|
-
# :abcdef.casecmp(:ABCDEF) #=> 0
|
88
|
-
#
|
89
|
-
# `nil` is returned if the two symbols have incompatible encodings, or if
|
90
|
-
# `other_symbol` is not a symbol.
|
91
|
-
#
|
92
|
-
# :foo.casecmp(2) #=> nil
|
93
|
-
# "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp(:"\u{c4 d6 dc}") #=> nil
|
94
|
-
#
|
95
|
-
def casecmp: (untyped other) -> Integer?
|
96
|
-
|
97
|
-
# Returns `true` if `sym` and `other_symbol` are equal after Unicode case
|
98
|
-
# folding, `false` if they are not equal.
|
99
|
-
#
|
100
|
-
# :aBcDeF.casecmp?(:abcde) #=> false
|
101
|
-
# :aBcDeF.casecmp?(:abcdef) #=> true
|
102
|
-
# :aBcDeF.casecmp?(:abcdefg) #=> false
|
103
|
-
# :abcdef.casecmp?(:ABCDEF) #=> true
|
104
|
-
# :"\u{e4 f6 fc}".casecmp?(:"\u{c4 d6 dc}") #=> true
|
105
|
-
#
|
106
|
-
# `nil` is returned if the two symbols have incompatible encodings, or if
|
107
|
-
# `other_symbol` is not a symbol.
|
108
|
-
#
|
109
|
-
# :foo.casecmp?(2) #=> nil
|
110
|
-
# "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp?(:"\u{c4 d6 dc}") #=> nil
|
111
|
-
#
|
112
|
-
def casecmp?: (untyped other) -> bool
|
113
|
-
|
114
|
-
# Same as `sym.to_s.downcase.intern`.
|
115
|
-
#
|
116
|
-
def downcase: () -> Symbol
|
117
|
-
| (:ascii | :fold | :lithuanian | :turkic) -> Symbol
|
118
|
-
| (:lithuanian, :turkic) -> Symbol
|
119
|
-
| (:turkic, :lithuanian) -> Symbol
|
120
|
-
|
121
|
-
# Returns whether *sym* is :"" or not.
|
122
|
-
#
|
123
|
-
def empty?: () -> bool
|
124
|
-
|
125
|
-
# Returns the Encoding object that represents the encoding of *sym*.
|
126
|
-
#
|
127
|
-
def encoding: () -> Encoding
|
128
|
-
|
129
|
-
# Returns true if `sym` ends with one of the `suffixes` given.
|
130
|
-
#
|
131
|
-
# :hello.end_with?("ello") #=> true
|
132
|
-
#
|
133
|
-
# # returns true if one of the +suffixes+ matches.
|
134
|
-
# :hello.end_with?("heaven", "ello") #=> true
|
135
|
-
# :hello.end_with?("heaven", "paradise") #=> false
|
136
|
-
#
|
137
|
-
def end_with?: (*string suffixes) -> bool
|
138
|
-
|
139
|
-
# Returns the name or string corresponding to *sym*.
|
140
|
-
#
|
141
|
-
# :fred.id2name #=> "fred"
|
142
|
-
# :ginger.to_s #=> "ginger"
|
143
|
-
#
|
144
|
-
def id2name: () -> String
|
145
|
-
|
146
|
-
# Returns the representation of *sym* as a symbol literal.
|
147
|
-
#
|
148
|
-
# :fred.inspect #=> ":fred"
|
149
|
-
#
|
150
|
-
def inspect: () -> String
|
151
|
-
|
152
|
-
# In general, `to_sym` returns the Symbol corresponding to an object. As *sym*
|
153
|
-
# is already a symbol, `self` is returned in this case.
|
154
|
-
#
|
155
|
-
def intern: () -> self
|
156
|
-
|
157
|
-
# Same as `sym.to_s.length`.
|
158
|
-
#
|
159
|
-
def length: () -> Integer
|
160
|
-
|
161
|
-
# Returns `sym.to_s.match`.
|
162
|
-
#
|
163
|
-
def match: (Regexp | string pattern, ?int pos) -> MatchData?
|
164
|
-
| (Regexp | string pattern, ?int pos) { (MatchData) -> void } -> untyped
|
165
|
-
|
166
|
-
# Returns `sym.to_s.match?`.
|
167
|
-
#
|
168
|
-
def match?: (Regexp | string pattern, ?int pos) -> bool
|
169
|
-
|
170
|
-
# Same as `sym.to_s.succ.intern`.
|
171
|
-
#
|
172
|
-
def next: () -> Symbol
|
173
|
-
|
174
|
-
# Same as `sym.to_s.length`.
|
175
|
-
#
|
176
|
-
alias size length
|
177
|
-
|
178
|
-
# Returns `sym.to_s[]`.
|
179
|
-
#
|
180
|
-
alias slice `[]`
|
181
|
-
|
182
|
-
# Returns true if `sym` starts with one of the `prefixes` given. Each of the
|
183
|
-
# `prefixes` should be a String or a Regexp.
|
184
|
-
#
|
185
|
-
# :hello.start_with?("hell") #=> true
|
186
|
-
# :hello.start_with?(/H/i) #=> true
|
187
|
-
#
|
188
|
-
# # returns true if one of the prefixes matches.
|
189
|
-
# :hello.start_with?("heaven", "hell") #=> true
|
190
|
-
# :hello.start_with?("heaven", "paradise") #=> false
|
191
|
-
def start_with?: (*string prefixes) -> bool
|
192
|
-
|
193
|
-
# Same as `sym.to_s.succ.intern`.
|
194
|
-
#
|
195
|
-
alias succ next
|
196
|
-
|
197
|
-
# Same as `sym.to_s.swapcase.intern`.
|
198
|
-
#
|
199
|
-
def swapcase: () -> Symbol
|
200
|
-
| (:ascii | :lithuanian | :turkic) -> Symbol
|
201
|
-
| (:lithuanian, :turkic) -> Symbol
|
202
|
-
| (:turkic, :lithuanian) -> Symbol
|
203
|
-
|
204
|
-
# Returns a *Proc* object which responds to the given method by *sym*.
|
205
|
-
#
|
206
|
-
# (1..3).collect(&:to_s) #=> ["1", "2", "3"]
|
207
|
-
#
|
208
|
-
def to_proc: () -> Proc
|
209
|
-
|
210
|
-
# Returns the name or string corresponding to *sym*.
|
211
|
-
#
|
212
|
-
# :fred.id2name #=> "fred"
|
213
|
-
# :ginger.to_s #=> "ginger"
|
214
|
-
#
|
215
|
-
alias to_s id2name
|
216
|
-
|
217
|
-
# In general, `to_sym` returns the Symbol corresponding to an object. As *sym*
|
218
|
-
# is already a symbol, `self` is returned in this case.
|
219
|
-
#
|
220
|
-
alias to_sym intern
|
221
|
-
|
222
|
-
# Same as `sym.to_s.upcase.intern`.
|
223
|
-
#
|
224
|
-
def upcase: () -> Symbol
|
225
|
-
| (:ascii | :lithuanian | :turkic) -> Symbol
|
226
|
-
| (:lithuanian, :turkic) -> Symbol
|
227
|
-
| (:turkic, :lithuanian) -> Symbol
|
228
|
-
end
|