steep 0.14.0 → 0.16.3
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 +25 -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.rb +18 -2
- data/lib/steep/annotation_parser.rb +4 -4
- data/lib/steep/ast/buffer.rb +11 -7
- data/lib/steep/ast/builtin.rb +8 -0
- data/lib/steep/ast/types/factory.rb +55 -55
- data/lib/steep/cli.rb +16 -1
- data/lib/steep/drivers/annotations.rb +1 -1
- data/lib/steep/drivers/check.rb +20 -4
- data/lib/steep/drivers/langserver.rb +13 -457
- data/lib/steep/drivers/utils/driver_helper.rb +1 -1
- data/lib/steep/drivers/vendor.rb +2 -2
- data/lib/steep/drivers/watch.rb +97 -85
- data/lib/steep/drivers/worker.rb +51 -0
- data/lib/steep/project.rb +9 -5
- data/lib/steep/project/completion_provider.rb +9 -13
- data/lib/steep/project/dsl.rb +14 -0
- data/lib/steep/project/file.rb +43 -46
- data/lib/steep/project/hover_content.rb +17 -8
- data/lib/steep/project/options.rb +25 -3
- data/lib/steep/project/target.rb +40 -24
- data/lib/steep/server/base_worker.rb +56 -0
- data/lib/steep/server/code_worker.rb +151 -0
- data/lib/steep/server/interaction_worker.rb +281 -0
- data/lib/steep/server/master.rb +196 -0
- data/lib/steep/server/signature_worker.rb +148 -0
- data/lib/steep/server/utils.rb +36 -0
- data/lib/steep/server/worker_process.rb +62 -0
- data/lib/steep/signature/errors.rb +1 -1
- data/lib/steep/signature/validator.rb +13 -13
- data/lib/steep/source.rb +1 -1
- data/lib/steep/type_construction.rb +996 -726
- data/lib/steep/type_inference/constant_env.rb +3 -11
- data/lib/steep/type_inference/context.rb +8 -3
- data/lib/steep/type_inference/context_array.rb +111 -0
- data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
- data/lib/steep/type_inference/logic.rb +130 -0
- data/lib/steep/type_inference/type_env.rb +5 -69
- data/lib/steep/typing.rb +79 -22
- data/lib/steep/version.rb +1 -1
- data/smoke/alias/Steepfile +1 -0
- data/smoke/and/Steepfile +1 -0
- data/smoke/array/Steepfile +1 -0
- data/smoke/array/b.rb +0 -2
- data/smoke/block/Steepfile +1 -0
- data/smoke/case/Steepfile +1 -0
- data/smoke/class/Steepfile +1 -0
- data/smoke/const/Steepfile +1 -0
- data/smoke/dstr/Steepfile +1 -0
- data/smoke/ensure/Steepfile +1 -0
- data/smoke/enumerator/Steepfile +1 -0
- data/smoke/extension/Steepfile +1 -0
- data/smoke/extension/c.rb +1 -0
- data/smoke/hash/Steepfile +1 -0
- data/smoke/hello/Steepfile +1 -0
- data/smoke/if/Steepfile +1 -0
- data/smoke/if/a.rb +1 -1
- data/smoke/implements/Steepfile +1 -0
- data/smoke/initialize/Steepfile +1 -0
- data/smoke/integer/Steepfile +1 -0
- data/smoke/interface/Steepfile +1 -0
- data/smoke/kwbegin/Steepfile +1 -0
- data/smoke/lambda/Steepfile +1 -0
- data/smoke/literal/Steepfile +1 -0
- data/smoke/map/Steepfile +1 -0
- data/smoke/method/Steepfile +1 -0
- data/smoke/module/Steepfile +1 -0
- data/smoke/regexp/Steepfile +1 -0
- data/smoke/regression/Steepfile +1 -0
- data/smoke/rescue/Steepfile +1 -0
- data/smoke/rescue/a.rb +1 -1
- data/smoke/self/Steepfile +1 -0
- data/smoke/skip/Steepfile +1 -0
- data/smoke/stdout/Steepfile +1 -0
- data/smoke/super/Steepfile +1 -0
- data/smoke/type_case/Steepfile +1 -0
- data/smoke/yield/Steepfile +1 -0
- data/steep.gemspec +7 -8
- metadata +26 -141
- data/exe/rbs +0 -3
- data/exe/ruby-signature +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 -67
- data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -156
- 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 -88
- data/vendor/ruby-signature/bin/test_runner.rb +0 -17
- 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 -3
- data/vendor/ruby-signature/exe/ruby-signature +0 -7
- data/vendor/ruby-signature/lib/ruby/signature.rb +0 -64
- data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
- data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
- data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
- data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
- data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
- data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
- data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -555
- data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
- data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
- data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
- data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
- data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
- data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
- data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
- data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
- data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
- data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
- data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
- data/vendor/ruby-signature/lib/ruby/signature/parser.y +0 -1344
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -444
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
- data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
- data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
- data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
- data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
- data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
- data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +0 -58
- data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -327
- data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
- data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
- data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
- data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
- data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
- data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
- data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
- data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
- data/vendor/ruby-signature/ruby-signature.gemspec +0 -45
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -3
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -15
- 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 -35
- 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 -419
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -606
- 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 -193
- 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 -476
- 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 -121
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -710
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -574
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -135
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -271
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -66
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -182
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -248
- 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 -426
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -354
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -93
- 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 -10
- 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 -1894
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -13
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -230
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1112
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -739
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -91
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -159
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -18
- data/vendor/ruby-signature/stdlib/find/find.rbs +0 -44
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -21
- 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 -77
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,409 +0,0 @@
|
|
1
|
-
# Numeric is the class from which all higher-level numeric classes should
|
2
|
-
# inherit.
|
3
|
-
#
|
4
|
-
# Numeric allows instantiation of heap-allocated objects. Other core numeric
|
5
|
-
# classes such as Integer are implemented as immediates, which means that each
|
6
|
-
# Integer is a single immutable object which is always passed by value.
|
7
|
-
#
|
8
|
-
# a = 1
|
9
|
-
# 1.object_id == a.object_id #=> true
|
10
|
-
#
|
11
|
-
# There can only ever be one instance of the integer `1`, for example. Ruby
|
12
|
-
# ensures this by preventing instantiation. If duplication is attempted, the
|
13
|
-
# same instance is returned.
|
14
|
-
#
|
15
|
-
# Integer.new(1) #=> NoMethodError: undefined method `new' for Integer:Class
|
16
|
-
# 1.dup #=> 1
|
17
|
-
# 1.object_id == 1.dup.object_id #=> true
|
18
|
-
#
|
19
|
-
# For this reason, Numeric should be used when defining other numeric classes.
|
20
|
-
#
|
21
|
-
# Classes which inherit from Numeric must implement `coerce`, which returns a
|
22
|
-
# two-member Array containing an object that has been coerced into an instance
|
23
|
-
# of the new class and `self` (see #coerce).
|
24
|
-
#
|
25
|
-
# Inheriting classes should also implement arithmetic operator methods (`+`,
|
26
|
-
# `-`, `*` and `/`) and the `<=>` operator (see Comparable). These methods may
|
27
|
-
# rely on `coerce` to ensure interoperability with instances of other numeric
|
28
|
-
# classes.
|
29
|
-
#
|
30
|
-
# class Tally < Numeric
|
31
|
-
# def initialize(string)
|
32
|
-
# @string = string
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# def to_s
|
36
|
-
# @string
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# def to_i
|
40
|
-
# @string.size
|
41
|
-
# end
|
42
|
-
#
|
43
|
-
# def coerce(other)
|
44
|
-
# [self.class.new('|' * other.to_i), self]
|
45
|
-
# end
|
46
|
-
#
|
47
|
-
# def <=>(other)
|
48
|
-
# to_i <=> other.to_i
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# def +(other)
|
52
|
-
# self.class.new('|' * (to_i + other.to_i))
|
53
|
-
# end
|
54
|
-
#
|
55
|
-
# def -(other)
|
56
|
-
# self.class.new('|' * (to_i - other.to_i))
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# def *(other)
|
60
|
-
# self.class.new('|' * (to_i * other.to_i))
|
61
|
-
# end
|
62
|
-
#
|
63
|
-
# def /(other)
|
64
|
-
# self.class.new('|' * (to_i / other.to_i))
|
65
|
-
# end
|
66
|
-
# end
|
67
|
-
#
|
68
|
-
# tally = Tally.new('||')
|
69
|
-
# puts tally * 2 #=> "||||"
|
70
|
-
# puts tally > 1 #=> true
|
71
|
-
#
|
72
|
-
class Numeric
|
73
|
-
include Comparable
|
74
|
-
|
75
|
-
public
|
76
|
-
|
77
|
-
# `x.modulo(y)` means `x-y*(x/y).floor`.
|
78
|
-
#
|
79
|
-
# Equivalent to `num.divmod(numeric)[1]`.
|
80
|
-
#
|
81
|
-
# See Numeric#divmod.
|
82
|
-
#
|
83
|
-
def %: (Numeric) -> Numeric
|
84
|
-
|
85
|
-
# Unary Plus---Returns the receiver.
|
86
|
-
#
|
87
|
-
def +@: () -> Numeric
|
88
|
-
|
89
|
-
# Unary Minus---Returns the receiver, negated.
|
90
|
-
#
|
91
|
-
def -@: () -> Numeric
|
92
|
-
|
93
|
-
# Returns zero if `number` equals `other`, otherwise returns `nil`.
|
94
|
-
#
|
95
|
-
def <=>: (Numeric other) -> Integer
|
96
|
-
|
97
|
-
# Returns the absolute value of `num`.
|
98
|
-
#
|
99
|
-
# 12.abs #=> 12
|
100
|
-
# (-34.56).abs #=> 34.56
|
101
|
-
# -34.56.abs #=> 34.56
|
102
|
-
#
|
103
|
-
# Numeric#magnitude is an alias for Numeric#abs.
|
104
|
-
#
|
105
|
-
def abs: () -> Numeric
|
106
|
-
|
107
|
-
# Returns square of self.
|
108
|
-
#
|
109
|
-
def abs2: () -> Numeric
|
110
|
-
|
111
|
-
# Returns 0 if the value is positive, pi otherwise.
|
112
|
-
#
|
113
|
-
def angle: () -> Numeric
|
114
|
-
|
115
|
-
# Returns 0 if the value is positive, pi otherwise.
|
116
|
-
#
|
117
|
-
alias arg angle
|
118
|
-
|
119
|
-
# Returns the smallest number greater than or equal to `num` with a precision of
|
120
|
-
# `ndigits` decimal digits (default: 0).
|
121
|
-
#
|
122
|
-
# Numeric implements this by converting its value to a Float and invoking
|
123
|
-
# Float#ceil.
|
124
|
-
#
|
125
|
-
def ceil: () -> Integer
|
126
|
-
| (Integer digits) -> (Integer | Numeric)
|
127
|
-
|
128
|
-
# If `numeric` is the same type as `num`, returns an array `[numeric, num]`.
|
129
|
-
# Otherwise, returns an array with both `numeric` and `num` represented as Float
|
130
|
-
# objects.
|
131
|
-
#
|
132
|
-
# This coercion mechanism is used by Ruby to handle mixed-type numeric
|
133
|
-
# operations: it is intended to find a compatible common type between the two
|
134
|
-
# operands of the operator.
|
135
|
-
#
|
136
|
-
# 1.coerce(2.5) #=> [2.5, 1.0]
|
137
|
-
# 1.2.coerce(3) #=> [3.0, 1.2]
|
138
|
-
# 1.coerce(2) #=> [2, 1]
|
139
|
-
#
|
140
|
-
def coerce: (Numeric) -> [ Numeric, Numeric ]
|
141
|
-
|
142
|
-
# Returns self.
|
143
|
-
#
|
144
|
-
def conj: () -> Numeric
|
145
|
-
|
146
|
-
# Returns self.
|
147
|
-
#
|
148
|
-
def conjugate: () -> Numeric
|
149
|
-
|
150
|
-
# Returns the denominator (always positive).
|
151
|
-
#
|
152
|
-
def denominator: () -> Integer
|
153
|
-
|
154
|
-
# Uses `/` to perform division, then converts the result to an integer. Numeric
|
155
|
-
# does not define the `/` operator; this is left to subclasses.
|
156
|
-
#
|
157
|
-
# Equivalent to `num.divmod(numeric)[0]`.
|
158
|
-
#
|
159
|
-
# See Numeric#divmod.
|
160
|
-
#
|
161
|
-
def div: (Numeric) -> Integer
|
162
|
-
|
163
|
-
# Returns an array containing the quotient and modulus obtained by dividing
|
164
|
-
# `num` by `numeric`.
|
165
|
-
#
|
166
|
-
# If `q, r = x.divmod(y)`, then
|
167
|
-
#
|
168
|
-
# q = floor(x/y)
|
169
|
-
# x = q*y + r
|
170
|
-
#
|
171
|
-
# The quotient is rounded toward negative infinity, as shown in the following
|
172
|
-
# table:
|
173
|
-
#
|
174
|
-
# a | b | a.divmod(b) | a/b | a.modulo(b) | a.remainder(b)
|
175
|
-
# ------+-----+---------------+---------+-------------+---------------
|
176
|
-
# 13 | 4 | 3, 1 | 3 | 1 | 1
|
177
|
-
# ------+-----+---------------+---------+-------------+---------------
|
178
|
-
# 13 | -4 | -4, -3 | -4 | -3 | 1
|
179
|
-
# ------+-----+---------------+---------+-------------+---------------
|
180
|
-
# -13 | 4 | -4, 3 | -4 | 3 | -1
|
181
|
-
# ------+-----+---------------+---------+-------------+---------------
|
182
|
-
# -13 | -4 | 3, -1 | 3 | -1 | -1
|
183
|
-
# ------+-----+---------------+---------+-------------+---------------
|
184
|
-
# 11.5 | 4 | 2, 3.5 | 2.875 | 3.5 | 3.5
|
185
|
-
# ------+-----+---------------+---------+-------------+---------------
|
186
|
-
# 11.5 | -4 | -3, -0.5 | -2.875 | -0.5 | 3.5
|
187
|
-
# ------+-----+---------------+---------+-------------+---------------
|
188
|
-
# -11.5 | 4 | -3, 0.5 | -2.875 | 0.5 | -3.5
|
189
|
-
# ------+-----+---------------+---------+-------------+---------------
|
190
|
-
# -11.5 | -4 | 2, -3.5 | 2.875 | -3.5 | -3.5
|
191
|
-
#
|
192
|
-
# Examples
|
193
|
-
#
|
194
|
-
# 11.divmod(3) #=> [3, 2]
|
195
|
-
# 11.divmod(-3) #=> [-4, -1]
|
196
|
-
# 11.divmod(3.5) #=> [3, 0.5]
|
197
|
-
# (-11).divmod(3.5) #=> [-4, 3.0]
|
198
|
-
# 11.5.divmod(3.5) #=> [3, 1.0]
|
199
|
-
#
|
200
|
-
def divmod: (Numeric) -> [ Numeric, Numeric ]
|
201
|
-
|
202
|
-
# Returns `true` if `num` and `numeric` are the same type and have equal values.
|
203
|
-
# Contrast this with Numeric#==, which performs type conversions.
|
204
|
-
#
|
205
|
-
# 1 == 1.0 #=> true
|
206
|
-
# 1.eql?(1.0) #=> false
|
207
|
-
# 1.0.eql?(1.0) #=> true
|
208
|
-
#
|
209
|
-
def eql?: (untyped) -> bool
|
210
|
-
|
211
|
-
# Returns float division.
|
212
|
-
#
|
213
|
-
def fdiv: (Numeric) -> Numeric
|
214
|
-
|
215
|
-
# Returns `true` if `num` is a finite number, otherwise returns `false`.
|
216
|
-
#
|
217
|
-
def finite?: () -> bool
|
218
|
-
|
219
|
-
# Returns the largest number less than or equal to `num` with a precision of
|
220
|
-
# `ndigits` decimal digits (default: 0).
|
221
|
-
#
|
222
|
-
# Numeric implements this by converting its value to a Float and invoking
|
223
|
-
# Float#floor.
|
224
|
-
#
|
225
|
-
def floor: () -> Integer
|
226
|
-
| (Integer digits) -> Numeric
|
227
|
-
|
228
|
-
# Returns the corresponding imaginary number. Not available for complex numbers.
|
229
|
-
#
|
230
|
-
# -42.i #=> (0-42i)
|
231
|
-
# 2.0.i #=> (0+2.0i)
|
232
|
-
#
|
233
|
-
def i: () -> Complex
|
234
|
-
|
235
|
-
# Returns zero.
|
236
|
-
#
|
237
|
-
def imag: () -> Numeric
|
238
|
-
|
239
|
-
# Returns zero.
|
240
|
-
#
|
241
|
-
def imaginary: () -> Numeric
|
242
|
-
|
243
|
-
# Returns `nil`, -1, or 1 depending on whether the value is finite, `-Infinity`,
|
244
|
-
# or `+Infinity`.
|
245
|
-
#
|
246
|
-
def infinite?: () -> Integer?
|
247
|
-
|
248
|
-
# Returns `true` if `num` is an Integer.
|
249
|
-
#
|
250
|
-
# 1.0.integer? #=> false
|
251
|
-
# 1.integer? #=> true
|
252
|
-
#
|
253
|
-
def integer?: () -> bool
|
254
|
-
|
255
|
-
# Returns the absolute value of `num`.
|
256
|
-
#
|
257
|
-
# 12.abs #=> 12
|
258
|
-
# (-34.56).abs #=> 34.56
|
259
|
-
# -34.56.abs #=> 34.56
|
260
|
-
#
|
261
|
-
# Numeric#magnitude is an alias for Numeric#abs.
|
262
|
-
#
|
263
|
-
alias magnitude abs
|
264
|
-
|
265
|
-
# `x.modulo(y)` means `x-y*(x/y).floor`.
|
266
|
-
#
|
267
|
-
# Equivalent to `num.divmod(numeric)[1]`.
|
268
|
-
#
|
269
|
-
# See Numeric#divmod.
|
270
|
-
#
|
271
|
-
def modulo: (Numeric) -> Numeric
|
272
|
-
|
273
|
-
# Returns `true` if `num` is less than 0.
|
274
|
-
#
|
275
|
-
def negative?: () -> bool
|
276
|
-
|
277
|
-
# Returns `self` if `num` is not zero, `nil` otherwise.
|
278
|
-
#
|
279
|
-
# This behavior is useful when chaining comparisons:
|
280
|
-
#
|
281
|
-
# a = %w( z Bb bB bb BB a aA Aa AA A )
|
282
|
-
# b = a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
|
283
|
-
# b #=> ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
|
284
|
-
#
|
285
|
-
def nonzero?: () -> self?
|
286
|
-
|
287
|
-
# Returns the numerator.
|
288
|
-
#
|
289
|
-
def numerator: () -> Numeric
|
290
|
-
|
291
|
-
# Returns 0 if the value is positive, pi otherwise.
|
292
|
-
#
|
293
|
-
alias phase angle
|
294
|
-
|
295
|
-
# Returns an array; [num.abs, num.arg].
|
296
|
-
#
|
297
|
-
def polar: () -> [ Numeric, Numeric ]
|
298
|
-
|
299
|
-
# Returns `true` if `num` is greater than 0.
|
300
|
-
#
|
301
|
-
def positive?: () -> bool
|
302
|
-
|
303
|
-
# Returns the most exact division (rational for integers, float for floats).
|
304
|
-
#
|
305
|
-
def quo: (Numeric) -> Numeric
|
306
|
-
|
307
|
-
# Returns self.
|
308
|
-
#
|
309
|
-
def real: () -> Numeric
|
310
|
-
|
311
|
-
# Returns `true` if `num` is a real number (i.e. not Complex).
|
312
|
-
#
|
313
|
-
def real?: () -> bool
|
314
|
-
|
315
|
-
# Returns an array; [num, 0].
|
316
|
-
#
|
317
|
-
def rect: () -> [ Numeric, Numeric ]
|
318
|
-
|
319
|
-
# Returns an array; [num, 0].
|
320
|
-
#
|
321
|
-
alias rectangular rect
|
322
|
-
|
323
|
-
# `x.remainder(y)` means `x-y*(x/y).truncate`.
|
324
|
-
#
|
325
|
-
# See Numeric#divmod.
|
326
|
-
#
|
327
|
-
def remainder: (Numeric) -> Numeric
|
328
|
-
|
329
|
-
# Returns `num` rounded to the nearest value with a precision of `ndigits`
|
330
|
-
# decimal digits (default: 0).
|
331
|
-
#
|
332
|
-
# Numeric implements this by converting its value to a Float and invoking
|
333
|
-
# Float#round.
|
334
|
-
#
|
335
|
-
def round: () -> Integer
|
336
|
-
| (Integer digits) -> Numeric
|
337
|
-
|
338
|
-
# Invokes the given block with the sequence of numbers starting at `num`,
|
339
|
-
# incremented by `step` (defaulted to `1`) on each call.
|
340
|
-
#
|
341
|
-
# The loop finishes when the value to be passed to the block is greater than
|
342
|
-
# `limit` (if `step` is positive) or less than `limit` (if `step` is negative),
|
343
|
-
# where `limit` is defaulted to infinity.
|
344
|
-
#
|
345
|
-
# In the recommended keyword argument style, either or both of `step` and
|
346
|
-
# `limit` (default infinity) can be omitted. In the fixed position argument
|
347
|
-
# style, zero as a step (i.e. `num.step(limit, 0)`) is not allowed for
|
348
|
-
# historical compatibility reasons.
|
349
|
-
#
|
350
|
-
# If all the arguments are integers, the loop operates using an integer counter.
|
351
|
-
#
|
352
|
-
# If any of the arguments are floating point numbers, all are converted to
|
353
|
-
# floats, and the loop is executed *floor(n + n*Float::EPSILON) + 1* times,
|
354
|
-
# where *n = (limit - num)/step*.
|
355
|
-
#
|
356
|
-
# Otherwise, the loop starts at `num`, uses either the less-than (`<`) or
|
357
|
-
# greater-than (`>`) operator to compare the counter against `limit`, and
|
358
|
-
# increments itself using the `+` operator.
|
359
|
-
#
|
360
|
-
# If no block is given, an Enumerator is returned instead. Especially, the
|
361
|
-
# enumerator is an Enumerator::ArithmeticSequence if both `limit` and `step` are
|
362
|
-
# kind of Numeric or `nil`.
|
363
|
-
#
|
364
|
-
# For example:
|
365
|
-
#
|
366
|
-
# p 1.step.take(4)
|
367
|
-
# p 10.step(by: -1).take(4)
|
368
|
-
# 3.step(to: 5) {|i| print i, " " }
|
369
|
-
# 1.step(10, 2) {|i| print i, " " }
|
370
|
-
# Math::E.step(to: Math::PI, by: 0.2) {|f| print f, " " }
|
371
|
-
#
|
372
|
-
# Will produce:
|
373
|
-
#
|
374
|
-
# [1, 2, 3, 4]
|
375
|
-
# [10, 9, 8, 7]
|
376
|
-
# 3 4 5
|
377
|
-
# 1 3 5 7 9
|
378
|
-
# 2.718281828459045 2.9182818284590453 3.118281828459045
|
379
|
-
#
|
380
|
-
def step: (?Numeric limit, ?Numeric step) { (Numeric) -> void } -> self
|
381
|
-
| (?Numeric limit, ?Numeric step) -> Enumerator[Numeric, self]
|
382
|
-
| (?by: Numeric, ?to: Numeric) { (Numeric) -> void } -> self
|
383
|
-
| (?by: Numeric, ?to: Numeric) -> Enumerator[Numeric, self]
|
384
|
-
|
385
|
-
# Returns the value as a complex.
|
386
|
-
#
|
387
|
-
def to_c: () -> Complex
|
388
|
-
|
389
|
-
# Invokes the child class's `to_i` method to convert `num` to an integer.
|
390
|
-
#
|
391
|
-
# 1.0.class #=> Float
|
392
|
-
# 1.0.to_int.class #=> Integer
|
393
|
-
# 1.0.to_i.class #=> Integer
|
394
|
-
#
|
395
|
-
def to_int: () -> Integer
|
396
|
-
|
397
|
-
# Returns `num` truncated (toward zero) to a precision of `ndigits` decimal
|
398
|
-
# digits (default: 0).
|
399
|
-
#
|
400
|
-
# Numeric implements this by converting its value to a Float and invoking
|
401
|
-
# Float#truncate.
|
402
|
-
#
|
403
|
-
def truncate: () -> Integer
|
404
|
-
| (Integer ndigits) -> (Integer | Numeric)
|
405
|
-
|
406
|
-
# Returns `true` if `num` has a zero value.
|
407
|
-
#
|
408
|
-
def zero?: () -> bool
|
409
|
-
end
|
@@ -1,824 +0,0 @@
|
|
1
|
-
# Object is the default root of all Ruby objects. Object inherits from
|
2
|
-
# BasicObject which allows creating alternate object hierarchies. Methods on
|
3
|
-
# Object are available to all classes unless explicitly overridden.
|
4
|
-
#
|
5
|
-
# Object mixes in the Kernel module, making the built-in kernel functions
|
6
|
-
# globally accessible. Although the instance methods of Object are defined by
|
7
|
-
# the Kernel module, we have chosen to document them here for clarity.
|
8
|
-
#
|
9
|
-
# When referencing constants in classes inheriting from Object you do not need
|
10
|
-
# to use the full namespace. For example, referencing `File` inside `YourClass`
|
11
|
-
# will find the top-level File class.
|
12
|
-
#
|
13
|
-
# In the descriptions of Object's methods, the parameter *symbol* refers to a
|
14
|
-
# symbol, which is either a quoted string or a Symbol (such as `:name`).
|
15
|
-
#
|
16
|
-
class Object < BasicObject
|
17
|
-
include Kernel
|
18
|
-
|
19
|
-
# Returns true if two objects do not match (using the *=~* method), otherwise
|
20
|
-
# false.
|
21
|
-
#
|
22
|
-
def !~: (untyped) -> bool
|
23
|
-
|
24
|
-
# Returns 0 if `obj` and `other` are the same object or `obj == other`,
|
25
|
-
# otherwise nil.
|
26
|
-
#
|
27
|
-
# The `<=>` is used by various methods to compare objects, for example
|
28
|
-
# Enumerable#sort, Enumerable#max etc.
|
29
|
-
#
|
30
|
-
# Your implementation of `<=>` should return one of the following values: -1, 0,
|
31
|
-
# 1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
|
32
|
-
# 1 means self is bigger than other. Nil means the two values could not be
|
33
|
-
# compared.
|
34
|
-
#
|
35
|
-
# When you define `<=>`, you can include Comparable to gain the methods `<=`,
|
36
|
-
# `<`, `==`, `>=`, `>` and `between?`.
|
37
|
-
#
|
38
|
-
def <=>: (untyped) -> Integer?
|
39
|
-
|
40
|
-
# Case Equality -- For class Object, effectively the same as calling `#==`, but
|
41
|
-
# typically overridden by descendants to provide meaningful semantics in `case`
|
42
|
-
# statements.
|
43
|
-
#
|
44
|
-
def ===: (untyped) -> bool
|
45
|
-
|
46
|
-
# This method is deprecated.
|
47
|
-
#
|
48
|
-
# This is not only unuseful but also troublesome because it may hide a type
|
49
|
-
# error.
|
50
|
-
#
|
51
|
-
def =~: (untyped) -> bool
|
52
|
-
|
53
|
-
# Returns the class of *obj*. This method must always be called with an explicit
|
54
|
-
# receiver, as `class` is also a reserved word in Ruby.
|
55
|
-
#
|
56
|
-
# 1.class #=> Integer
|
57
|
-
# self.class #=> Object
|
58
|
-
#
|
59
|
-
def `class`: () -> untyped
|
60
|
-
|
61
|
-
# Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
|
62
|
-
# but not the objects they reference. `clone` copies the frozen (unless :freeze
|
63
|
-
# keyword argument is given with a false value) and tainted state of *obj*. See
|
64
|
-
# also the discussion under `Object#dup`.
|
65
|
-
#
|
66
|
-
# class Klass
|
67
|
-
# attr_accessor :str
|
68
|
-
# end
|
69
|
-
# s1 = Klass.new #=> #<Klass:0x401b3a38>
|
70
|
-
# s1.str = "Hello" #=> "Hello"
|
71
|
-
# s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello">
|
72
|
-
# s2.str[1,4] = "i" #=> "i"
|
73
|
-
# s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">"
|
74
|
-
# s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
|
75
|
-
#
|
76
|
-
# This method may have class-specific behavior. If so, that behavior will be
|
77
|
-
# documented under the #`initialize_copy` method of the class.
|
78
|
-
#
|
79
|
-
def clone: (?freeze: bool) -> self
|
80
|
-
|
81
|
-
# Defines a singleton method in the receiver. The *method* parameter can be a
|
82
|
-
# `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified, it
|
83
|
-
# is used as the method body.
|
84
|
-
#
|
85
|
-
# class A
|
86
|
-
# class << self
|
87
|
-
# def class_name
|
88
|
-
# to_s
|
89
|
-
# end
|
90
|
-
# end
|
91
|
-
# end
|
92
|
-
# A.define_singleton_method(:who_am_i) do
|
93
|
-
# "I am: #{class_name}"
|
94
|
-
# end
|
95
|
-
# A.who_am_i # ==> "I am: A"
|
96
|
-
#
|
97
|
-
# guy = "Bob"
|
98
|
-
# guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
|
99
|
-
# guy.hello #=> "Bob: Hello there!"
|
100
|
-
#
|
101
|
-
def define_singleton_method: (Symbol, Method | UnboundMethod) -> Symbol
|
102
|
-
| (Symbol) { (*untyped) -> untyped } -> Symbol
|
103
|
-
|
104
|
-
# Prints *obj* on the given port (default `$>`). Equivalent to:
|
105
|
-
#
|
106
|
-
# def display(port=$>)
|
107
|
-
# port.write self
|
108
|
-
# nil
|
109
|
-
# end
|
110
|
-
#
|
111
|
-
# For example:
|
112
|
-
#
|
113
|
-
# 1.display
|
114
|
-
# "cat".display
|
115
|
-
# [ 4, 5, 6 ].display
|
116
|
-
# puts
|
117
|
-
#
|
118
|
-
# *produces:*
|
119
|
-
#
|
120
|
-
# 1cat[4, 5, 6]
|
121
|
-
#
|
122
|
-
def display: (?_Writeable port) -> void
|
123
|
-
|
124
|
-
# Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
|
125
|
-
# but not the objects they reference. `dup` copies the tainted state of *obj*.
|
126
|
-
#
|
127
|
-
# This method may have class-specific behavior. If so, that behavior will be
|
128
|
-
# documented under the #`initialize_copy` method of the class.
|
129
|
-
#
|
130
|
-
# ### on dup vs clone
|
131
|
-
#
|
132
|
-
# In general, `clone` and `dup` may have different semantics in descendant
|
133
|
-
# classes. While `clone` is used to duplicate an object, including its internal
|
134
|
-
# state, `dup` typically uses the class of the descendant object to create the
|
135
|
-
# new instance.
|
136
|
-
#
|
137
|
-
# When using #dup, any modules that the object has been extended with will not
|
138
|
-
# be copied.
|
139
|
-
#
|
140
|
-
# class Klass
|
141
|
-
# attr_accessor :str
|
142
|
-
# end
|
143
|
-
#
|
144
|
-
# module Foo
|
145
|
-
# def foo; 'foo'; end
|
146
|
-
# end
|
147
|
-
#
|
148
|
-
# s1 = Klass.new #=> #<Klass:0x401b3a38>
|
149
|
-
# s1.extend(Foo) #=> #<Klass:0x401b3a38>
|
150
|
-
# s1.foo #=> "foo"
|
151
|
-
#
|
152
|
-
# s2 = s1.clone #=> #<Klass:0x401b3a38>
|
153
|
-
# s2.foo #=> "foo"
|
154
|
-
#
|
155
|
-
# s3 = s1.dup #=> #<Klass:0x401b3a38>
|
156
|
-
# s3.foo #=> NoMethodError: undefined method `foo' for #<Klass:0x401b3a38>
|
157
|
-
#
|
158
|
-
def dup: () -> self
|
159
|
-
|
160
|
-
# Creates a new Enumerator which will enumerate by calling `method` on `obj`,
|
161
|
-
# passing `args` if any.
|
162
|
-
#
|
163
|
-
# If a block is given, it will be used to calculate the size of the enumerator
|
164
|
-
# without the need to iterate it (see Enumerator#size).
|
165
|
-
#
|
166
|
-
# ### Examples
|
167
|
-
#
|
168
|
-
# str = "xyz"
|
169
|
-
#
|
170
|
-
# enum = str.enum_for(:each_byte)
|
171
|
-
# enum.each { |b| puts b }
|
172
|
-
# # => 120
|
173
|
-
# # => 121
|
174
|
-
# # => 122
|
175
|
-
#
|
176
|
-
# # protect an array from being modified by some_method
|
177
|
-
# a = [1, 2, 3]
|
178
|
-
# some_method(a.to_enum)
|
179
|
-
#
|
180
|
-
# It is typical to call to_enum when defining methods for a generic Enumerable,
|
181
|
-
# in case no block is passed.
|
182
|
-
#
|
183
|
-
# Here is such an example, with parameter passing and a sizing block:
|
184
|
-
#
|
185
|
-
# module Enumerable
|
186
|
-
# # a generic method to repeat the values of any enumerable
|
187
|
-
# def repeat(n)
|
188
|
-
# raise ArgumentError, "#{n} is negative!" if n < 0
|
189
|
-
# unless block_given?
|
190
|
-
# return to_enum(__method__, n) do # __method__ is :repeat here
|
191
|
-
# sz = size # Call size and multiply by n...
|
192
|
-
# sz * n if sz # but return nil if size itself is nil
|
193
|
-
# end
|
194
|
-
# end
|
195
|
-
# each do |*val|
|
196
|
-
# n.times { yield *val }
|
197
|
-
# end
|
198
|
-
# end
|
199
|
-
# end
|
200
|
-
#
|
201
|
-
# %i[hello world].repeat(2) { |w| puts w }
|
202
|
-
# # => Prints 'hello', 'hello', 'world', 'world'
|
203
|
-
# enum = (1..14).repeat(3)
|
204
|
-
# # => returns an Enumerator when called without a block
|
205
|
-
# enum.first(4) # => [1, 1, 1, 2]
|
206
|
-
# enum.size # => 42
|
207
|
-
#
|
208
|
-
def enum_for: (Symbol method, *untyped args) ?{ (*untyped args) -> Integer } -> Enumerator[untyped, untyped]
|
209
|
-
| (*untyped args) ?{ (*untyped args) -> Integer } -> Enumerator[untyped, untyped]
|
210
|
-
|
211
|
-
# Creates a new Enumerator which will enumerate by calling `method` on `obj`,
|
212
|
-
# passing `args` if any.
|
213
|
-
#
|
214
|
-
# If a block is given, it will be used to calculate the size of the enumerator
|
215
|
-
# without the need to iterate it (see Enumerator#size).
|
216
|
-
#
|
217
|
-
# ### Examples
|
218
|
-
#
|
219
|
-
# str = "xyz"
|
220
|
-
#
|
221
|
-
# enum = str.enum_for(:each_byte)
|
222
|
-
# enum.each { |b| puts b }
|
223
|
-
# # => 120
|
224
|
-
# # => 121
|
225
|
-
# # => 122
|
226
|
-
#
|
227
|
-
# # protect an array from being modified by some_method
|
228
|
-
# a = [1, 2, 3]
|
229
|
-
# some_method(a.to_enum)
|
230
|
-
#
|
231
|
-
# It is typical to call to_enum when defining methods for a generic Enumerable,
|
232
|
-
# in case no block is passed.
|
233
|
-
#
|
234
|
-
# Here is such an example, with parameter passing and a sizing block:
|
235
|
-
#
|
236
|
-
# module Enumerable
|
237
|
-
# # a generic method to repeat the values of any enumerable
|
238
|
-
# def repeat(n)
|
239
|
-
# raise ArgumentError, "#{n} is negative!" if n < 0
|
240
|
-
# unless block_given?
|
241
|
-
# return to_enum(__method__, n) do # __method__ is :repeat here
|
242
|
-
# sz = size # Call size and multiply by n...
|
243
|
-
# sz * n if sz # but return nil if size itself is nil
|
244
|
-
# end
|
245
|
-
# end
|
246
|
-
# each do |*val|
|
247
|
-
# n.times { yield *val }
|
248
|
-
# end
|
249
|
-
# end
|
250
|
-
# end
|
251
|
-
#
|
252
|
-
# %i[hello world].repeat(2) { |w| puts w }
|
253
|
-
# # => Prints 'hello', 'hello', 'world', 'world'
|
254
|
-
# enum = (1..14).repeat(3)
|
255
|
-
# # => returns an Enumerator when called without a block
|
256
|
-
# enum.first(4) # => [1, 1, 1, 2]
|
257
|
-
# enum.size # => 42
|
258
|
-
#
|
259
|
-
alias to_enum enum_for
|
260
|
-
|
261
|
-
# Equality --- At the `Object` level, `==` returns `true` only if `obj` and
|
262
|
-
# `other` are the same object. Typically, this method is overridden in
|
263
|
-
# descendant classes to provide class-specific meaning.
|
264
|
-
#
|
265
|
-
# Unlike `==`, the `equal?` method should never be overridden by subclasses as
|
266
|
-
# it is used to determine object identity (that is, `a.equal?(b)` if and only if
|
267
|
-
# `a` is the same object as `b`):
|
268
|
-
#
|
269
|
-
# obj = "a"
|
270
|
-
# other = obj.dup
|
271
|
-
#
|
272
|
-
# obj == other #=> true
|
273
|
-
# obj.equal? other #=> false
|
274
|
-
# obj.equal? obj #=> true
|
275
|
-
#
|
276
|
-
# The `eql?` method returns `true` if `obj` and `other` refer to the same hash
|
277
|
-
# key. This is used by Hash to test members for equality. For objects of class
|
278
|
-
# `Object`, `eql?` is synonymous with `==`. Subclasses normally continue this
|
279
|
-
# tradition by aliasing `eql?` to their overridden `==` method, but there are
|
280
|
-
# exceptions. `Numeric` types, for example, perform type conversion across
|
281
|
-
# `==`, but not across `eql?`, so:
|
282
|
-
#
|
283
|
-
# 1 == 1.0 #=> true
|
284
|
-
# 1.eql? 1.0 #=> false
|
285
|
-
#
|
286
|
-
def eql?: (untyped) -> bool
|
287
|
-
|
288
|
-
# Adds to *obj* the instance methods from each module given as a parameter.
|
289
|
-
#
|
290
|
-
# module Mod
|
291
|
-
# def hello
|
292
|
-
# "Hello from Mod.\n"
|
293
|
-
# end
|
294
|
-
# end
|
295
|
-
#
|
296
|
-
# class Klass
|
297
|
-
# def hello
|
298
|
-
# "Hello from Klass.\n"
|
299
|
-
# end
|
300
|
-
# end
|
301
|
-
#
|
302
|
-
# k = Klass.new
|
303
|
-
# k.hello #=> "Hello from Klass.\n"
|
304
|
-
# k.extend(Mod) #=> #<Klass:0x401b3bc8>
|
305
|
-
# k.hello #=> "Hello from Mod.\n"
|
306
|
-
#
|
307
|
-
def `extend`: (*Module) -> self
|
308
|
-
|
309
|
-
# Prevents further modifications to *obj*. A `RuntimeError` will be raised if
|
310
|
-
# modification is attempted. There is no way to unfreeze a frozen object. See
|
311
|
-
# also `Object#frozen?`.
|
312
|
-
#
|
313
|
-
# This method returns self.
|
314
|
-
#
|
315
|
-
# a = [ "a", "b", "c" ]
|
316
|
-
# a.freeze
|
317
|
-
# a << "z"
|
318
|
-
#
|
319
|
-
# *produces:*
|
320
|
-
#
|
321
|
-
# prog.rb:3:in `<<': can't modify frozen Array (FrozenError)
|
322
|
-
# from prog.rb:3
|
323
|
-
#
|
324
|
-
# Objects of the following classes are always frozen: Integer, Float, Symbol.
|
325
|
-
#
|
326
|
-
def freeze: () -> self
|
327
|
-
|
328
|
-
# Returns the freeze status of *obj*.
|
329
|
-
#
|
330
|
-
# a = [ "a", "b", "c" ]
|
331
|
-
# a.freeze #=> ["a", "b", "c"]
|
332
|
-
# a.frozen? #=> true
|
333
|
-
#
|
334
|
-
def frozen?: () -> bool
|
335
|
-
|
336
|
-
def hash: () -> Integer
|
337
|
-
|
338
|
-
# Returns a string containing a human-readable representation of *obj*. The
|
339
|
-
# default `inspect` shows the object's class name, an encoding of the object id,
|
340
|
-
# and a list of the instance variables and their values (by calling #inspect on
|
341
|
-
# each of them). User defined classes should override this method to provide a
|
342
|
-
# better representation of *obj*. When overriding this method, it should return
|
343
|
-
# a string whose encoding is compatible with the default external encoding.
|
344
|
-
#
|
345
|
-
# [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
|
346
|
-
# Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
|
347
|
-
#
|
348
|
-
# class Foo
|
349
|
-
# end
|
350
|
-
# Foo.new.inspect #=> "#<Foo:0x0300c868>"
|
351
|
-
#
|
352
|
-
# class Bar
|
353
|
-
# def initialize
|
354
|
-
# @bar = 1
|
355
|
-
# end
|
356
|
-
# end
|
357
|
-
# Bar.new.inspect #=> "#<Bar:0x0300c868 @bar=1>"
|
358
|
-
#
|
359
|
-
def inspect: () -> String
|
360
|
-
|
361
|
-
# Returns `true` if *obj* is an instance of the given class. See also
|
362
|
-
# `Object#kind_of?`.
|
363
|
-
#
|
364
|
-
# class A; end
|
365
|
-
# class B < A; end
|
366
|
-
# class C < B; end
|
367
|
-
#
|
368
|
-
# b = B.new
|
369
|
-
# b.instance_of? A #=> false
|
370
|
-
# b.instance_of? B #=> true
|
371
|
-
# b.instance_of? C #=> false
|
372
|
-
#
|
373
|
-
def instance_of?: (Module) -> bool
|
374
|
-
|
375
|
-
# Returns `true` if the given instance variable is defined in *obj*. String
|
376
|
-
# arguments are converted to symbols.
|
377
|
-
#
|
378
|
-
# class Fred
|
379
|
-
# def initialize(p1, p2)
|
380
|
-
# @a, @b = p1, p2
|
381
|
-
# end
|
382
|
-
# end
|
383
|
-
# fred = Fred.new('cat', 99)
|
384
|
-
# fred.instance_variable_defined?(:@a) #=> true
|
385
|
-
# fred.instance_variable_defined?("@b") #=> true
|
386
|
-
# fred.instance_variable_defined?("@c") #=> false
|
387
|
-
#
|
388
|
-
def instance_variable_defined?: (String | Symbol var) -> bool
|
389
|
-
|
390
|
-
# Returns the value of the given instance variable, or nil if the instance
|
391
|
-
# variable is not set. The `@` part of the variable name should be included for
|
392
|
-
# regular instance variables. Throws a `NameError` exception if the supplied
|
393
|
-
# symbol is not valid as an instance variable name. String arguments are
|
394
|
-
# converted to symbols.
|
395
|
-
#
|
396
|
-
# class Fred
|
397
|
-
# def initialize(p1, p2)
|
398
|
-
# @a, @b = p1, p2
|
399
|
-
# end
|
400
|
-
# end
|
401
|
-
# fred = Fred.new('cat', 99)
|
402
|
-
# fred.instance_variable_get(:@a) #=> "cat"
|
403
|
-
# fred.instance_variable_get("@b") #=> 99
|
404
|
-
#
|
405
|
-
def instance_variable_get: (String | Symbol var) -> untyped
|
406
|
-
|
407
|
-
# Sets the instance variable named by *symbol* to the given object, thereby
|
408
|
-
# frustrating the efforts of the class's author to attempt to provide proper
|
409
|
-
# encapsulation. The variable does not have to exist prior to this call. If the
|
410
|
-
# instance variable name is passed as a string, that string is converted to a
|
411
|
-
# symbol.
|
412
|
-
#
|
413
|
-
# class Fred
|
414
|
-
# def initialize(p1, p2)
|
415
|
-
# @a, @b = p1, p2
|
416
|
-
# end
|
417
|
-
# end
|
418
|
-
# fred = Fred.new('cat', 99)
|
419
|
-
# fred.instance_variable_set(:@a, 'dog') #=> "dog"
|
420
|
-
# fred.instance_variable_set(:@c, 'cat') #=> "cat"
|
421
|
-
# fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
|
422
|
-
#
|
423
|
-
def instance_variable_set: [X] (String | Symbol var, X value) -> X
|
424
|
-
|
425
|
-
# Returns an array of instance variable names for the receiver. Note that simply
|
426
|
-
# defining an accessor does not create the corresponding instance variable.
|
427
|
-
#
|
428
|
-
# class Fred
|
429
|
-
# attr_accessor :a1
|
430
|
-
# def initialize
|
431
|
-
# @iv = 3
|
432
|
-
# end
|
433
|
-
# end
|
434
|
-
# Fred.new.instance_variables #=> [:@iv]
|
435
|
-
#
|
436
|
-
def instance_variables: () -> Array[Symbol]
|
437
|
-
|
438
|
-
# Returns `true` if *class* is the class of *obj*, or if *class* is one of the
|
439
|
-
# superclasses of *obj* or modules included in *obj*.
|
440
|
-
#
|
441
|
-
# module M; end
|
442
|
-
# class A
|
443
|
-
# include M
|
444
|
-
# end
|
445
|
-
# class B < A; end
|
446
|
-
# class C < B; end
|
447
|
-
#
|
448
|
-
# b = B.new
|
449
|
-
# b.is_a? A #=> true
|
450
|
-
# b.is_a? B #=> true
|
451
|
-
# b.is_a? C #=> false
|
452
|
-
# b.is_a? M #=> true
|
453
|
-
#
|
454
|
-
# b.kind_of? A #=> true
|
455
|
-
# b.kind_of? B #=> true
|
456
|
-
# b.kind_of? C #=> false
|
457
|
-
# b.kind_of? M #=> true
|
458
|
-
#
|
459
|
-
def is_a?: (Module) -> bool
|
460
|
-
|
461
|
-
# Returns `true` if *class* is the class of *obj*, or if *class* is one of the
|
462
|
-
# superclasses of *obj* or modules included in *obj*.
|
463
|
-
#
|
464
|
-
# module M; end
|
465
|
-
# class A
|
466
|
-
# include M
|
467
|
-
# end
|
468
|
-
# class B < A; end
|
469
|
-
# class C < B; end
|
470
|
-
#
|
471
|
-
# b = B.new
|
472
|
-
# b.is_a? A #=> true
|
473
|
-
# b.is_a? B #=> true
|
474
|
-
# b.is_a? C #=> false
|
475
|
-
# b.is_a? M #=> true
|
476
|
-
#
|
477
|
-
# b.kind_of? A #=> true
|
478
|
-
# b.kind_of? B #=> true
|
479
|
-
# b.kind_of? C #=> false
|
480
|
-
# b.kind_of? M #=> true
|
481
|
-
#
|
482
|
-
alias kind_of? is_a?
|
483
|
-
|
484
|
-
# Returns the receiver.
|
485
|
-
#
|
486
|
-
# string = "my string"
|
487
|
-
# string.itself.object_id == string.object_id #=> true
|
488
|
-
#
|
489
|
-
def `itself`: () -> self
|
490
|
-
|
491
|
-
# Looks up the named method as a receiver in *obj*, returning a `Method` object
|
492
|
-
# (or raising `NameError`). The `Method` object acts as a closure in *obj*'s
|
493
|
-
# object instance, so instance variables and the value of `self` remain
|
494
|
-
# available.
|
495
|
-
#
|
496
|
-
# class Demo
|
497
|
-
# def initialize(n)
|
498
|
-
# @iv = n
|
499
|
-
# end
|
500
|
-
# def hello()
|
501
|
-
# "Hello, @iv = #{@iv}"
|
502
|
-
# end
|
503
|
-
# end
|
504
|
-
#
|
505
|
-
# k = Demo.new(99)
|
506
|
-
# m = k.method(:hello)
|
507
|
-
# m.call #=> "Hello, @iv = 99"
|
508
|
-
#
|
509
|
-
# l = Demo.new('Fred')
|
510
|
-
# m = l.method("hello")
|
511
|
-
# m.call #=> "Hello, @iv = Fred"
|
512
|
-
#
|
513
|
-
# Note that `Method` implements `to_proc` method, which means it can be used
|
514
|
-
# with iterators.
|
515
|
-
#
|
516
|
-
# [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
|
517
|
-
#
|
518
|
-
# out = File.open('test.txt', 'w')
|
519
|
-
# [ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file
|
520
|
-
#
|
521
|
-
# require 'date'
|
522
|
-
# %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
|
523
|
-
# #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
|
524
|
-
#
|
525
|
-
def method: (String | Symbol name) -> Method
|
526
|
-
|
527
|
-
# Returns a list of the names of public and protected methods of *obj*. This
|
528
|
-
# will include all the methods accessible in *obj*'s ancestors. If the optional
|
529
|
-
# parameter is `false`, it returns an array of *obj<i>'s public and protected
|
530
|
-
# singleton methods, the array will not include methods in modules included in
|
531
|
-
# <i>obj*.
|
532
|
-
#
|
533
|
-
# class Klass
|
534
|
-
# def klass_method()
|
535
|
-
# end
|
536
|
-
# end
|
537
|
-
# k = Klass.new
|
538
|
-
# k.methods[0..9] #=> [:klass_method, :nil?, :===,
|
539
|
-
# # :==~, :!, :eql?
|
540
|
-
# # :hash, :<=>, :class, :singleton_class]
|
541
|
-
# k.methods.length #=> 56
|
542
|
-
#
|
543
|
-
# k.methods(false) #=> []
|
544
|
-
# def k.singleton_method; end
|
545
|
-
# k.methods(false) #=> [:singleton_method]
|
546
|
-
#
|
547
|
-
# module M123; def m123; end end
|
548
|
-
# k.extend M123
|
549
|
-
# k.methods(false) #=> [:singleton_method]
|
550
|
-
#
|
551
|
-
def methods: () -> Array[Symbol]
|
552
|
-
|
553
|
-
# Only the object *nil* responds `true` to `nil?`.
|
554
|
-
#
|
555
|
-
# Object.new.nil? #=> false
|
556
|
-
# nil.nil? #=> true
|
557
|
-
#
|
558
|
-
def `nil?`: () -> bool
|
559
|
-
|
560
|
-
# Returns an integer identifier for `obj`.
|
561
|
-
#
|
562
|
-
# The same number will be returned on all calls to `object_id` for a given
|
563
|
-
# object, and no two active objects will share an id.
|
564
|
-
#
|
565
|
-
# Note: that some objects of builtin classes are reused for optimization. This
|
566
|
-
# is the case for immediate values and frozen string literals.
|
567
|
-
#
|
568
|
-
# Immediate values are not passed by reference but are passed by value: `nil`,
|
569
|
-
# `true`, `false`, Fixnums, Symbols, and some Floats.
|
570
|
-
#
|
571
|
-
# Object.new.object_id == Object.new.object_id # => false
|
572
|
-
# (21 * 2).object_id == (21 * 2).object_id # => true
|
573
|
-
# "hello".object_id == "hello".object_id # => false
|
574
|
-
# "hi".freeze.object_id == "hi".freeze.object_id # => true
|
575
|
-
#
|
576
|
-
def object_id: () -> Integer
|
577
|
-
|
578
|
-
# Returns the list of private methods accessible to *obj*. If the *all*
|
579
|
-
# parameter is set to `false`, only those methods in the receiver will be
|
580
|
-
# listed.
|
581
|
-
#
|
582
|
-
def private_methods: () -> Array[Symbol]
|
583
|
-
|
584
|
-
# Returns the list of protected methods accessible to *obj*. If the *all*
|
585
|
-
# parameter is set to `false`, only those methods in the receiver will be
|
586
|
-
# listed.
|
587
|
-
#
|
588
|
-
def protected_methods: () -> Array[Symbol]
|
589
|
-
|
590
|
-
# Similar to *method*, searches public method only.
|
591
|
-
#
|
592
|
-
def public_method: (name name) -> Method
|
593
|
-
|
594
|
-
# Invokes the method identified by *symbol*, passing it any arguments specified.
|
595
|
-
# Unlike send, public_send calls public methods only. When the method is
|
596
|
-
# identified by a string, the string is converted to a symbol.
|
597
|
-
#
|
598
|
-
# 1.public_send(:puts, "hello") # causes NoMethodError
|
599
|
-
#
|
600
|
-
def `public_send`: (name name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
|
601
|
-
|
602
|
-
# Removes the named instance variable from *obj*, returning that variable's
|
603
|
-
# value. String arguments are converted to symbols.
|
604
|
-
#
|
605
|
-
# class Dummy
|
606
|
-
# attr_reader :var
|
607
|
-
# def initialize
|
608
|
-
# @var = 99
|
609
|
-
# end
|
610
|
-
# def remove
|
611
|
-
# remove_instance_variable(:@var)
|
612
|
-
# end
|
613
|
-
# end
|
614
|
-
# d = Dummy.new
|
615
|
-
# d.var #=> 99
|
616
|
-
# d.remove #=> 99
|
617
|
-
# d.var #=> nil
|
618
|
-
#
|
619
|
-
def remove_instance_variable: (name name) -> untyped
|
620
|
-
|
621
|
-
# Returns `true` if *obj* responds to the given method. Private and protected
|
622
|
-
# methods are included in the search only if the optional second parameter
|
623
|
-
# evaluates to `true`.
|
624
|
-
#
|
625
|
-
# If the method is not implemented, as Process.fork on Windows, File.lchmod on
|
626
|
-
# GNU/Linux, etc., false is returned.
|
627
|
-
#
|
628
|
-
# If the method is not defined, `respond_to_missing?` method is called and the
|
629
|
-
# result is returned.
|
630
|
-
#
|
631
|
-
# When the method name parameter is given as a string, the string is converted
|
632
|
-
# to a symbol.
|
633
|
-
#
|
634
|
-
def respond_to?: (name name, ?bool include_all) -> bool
|
635
|
-
|
636
|
-
# Invokes the method identified by *symbol*, passing it any arguments specified.
|
637
|
-
# You can use `__send__` if the name `send` clashes with an existing method in
|
638
|
-
# *obj*. When the method is identified by a string, the string is converted to a
|
639
|
-
# symbol.
|
640
|
-
#
|
641
|
-
# class Klass
|
642
|
-
# def hello(*args)
|
643
|
-
# "Hello " + args.join(' ')
|
644
|
-
# end
|
645
|
-
# end
|
646
|
-
# k = Klass.new
|
647
|
-
# k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
|
648
|
-
#
|
649
|
-
def `send`: (name name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
|
650
|
-
|
651
|
-
# Returns the singleton class of *obj*. This method creates a new singleton
|
652
|
-
# class if *obj* does not have one.
|
653
|
-
#
|
654
|
-
# If *obj* is `nil`, `true`, or `false`, it returns NilClass, TrueClass, or
|
655
|
-
# FalseClass, respectively. If *obj* is an Integer, a Float or a Symbol, it
|
656
|
-
# raises a TypeError.
|
657
|
-
#
|
658
|
-
# Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
|
659
|
-
# String.singleton_class #=> #<Class:String>
|
660
|
-
# nil.singleton_class #=> NilClass
|
661
|
-
#
|
662
|
-
def `singleton_class`: () -> Class
|
663
|
-
|
664
|
-
# Similar to *method*, searches singleton method only.
|
665
|
-
#
|
666
|
-
# class Demo
|
667
|
-
# def initialize(n)
|
668
|
-
# @iv = n
|
669
|
-
# end
|
670
|
-
# def hello()
|
671
|
-
# "Hello, @iv = #{@iv}"
|
672
|
-
# end
|
673
|
-
# end
|
674
|
-
#
|
675
|
-
# k = Demo.new(99)
|
676
|
-
# def k.hi
|
677
|
-
# "Hi, @iv = #{@iv}"
|
678
|
-
# end
|
679
|
-
# m = k.singleton_method(:hi)
|
680
|
-
# m.call #=> "Hi, @iv = 99"
|
681
|
-
# m = k.singleton_method(:hello) #=> NameError
|
682
|
-
#
|
683
|
-
def singleton_method: (name name) -> Method
|
684
|
-
|
685
|
-
# Returns an array of the names of singleton methods for *obj*. If the optional
|
686
|
-
# *all* parameter is true, the list will include methods in modules included in
|
687
|
-
# *obj*. Only public and protected singleton methods are returned.
|
688
|
-
#
|
689
|
-
# module Other
|
690
|
-
# def three() end
|
691
|
-
# end
|
692
|
-
#
|
693
|
-
# class Single
|
694
|
-
# def Single.four() end
|
695
|
-
# end
|
696
|
-
#
|
697
|
-
# a = Single.new
|
698
|
-
#
|
699
|
-
# def a.one()
|
700
|
-
# end
|
701
|
-
#
|
702
|
-
# class << a
|
703
|
-
# include Other
|
704
|
-
# def two()
|
705
|
-
# end
|
706
|
-
# end
|
707
|
-
#
|
708
|
-
# Single.singleton_methods #=> [:four]
|
709
|
-
# a.singleton_methods(false) #=> [:two, :one]
|
710
|
-
# a.singleton_methods #=> [:two, :one, :three]
|
711
|
-
#
|
712
|
-
def singleton_methods: () -> Array[Symbol]
|
713
|
-
|
714
|
-
# Mark the object as tainted.
|
715
|
-
#
|
716
|
-
# Objects that are marked as tainted will be restricted from various built-in
|
717
|
-
# methods. This is to prevent insecure data, such as command-line arguments or
|
718
|
-
# strings read from Kernel#gets, from inadvertently compromising the user's
|
719
|
-
# system.
|
720
|
-
#
|
721
|
-
# To check whether an object is tainted, use #tainted?.
|
722
|
-
#
|
723
|
-
# You should only untaint a tainted object if your code has inspected it and
|
724
|
-
# determined that it is safe. To do so use #untaint.
|
725
|
-
#
|
726
|
-
def taint: () -> self
|
727
|
-
|
728
|
-
# Deprecated method that is equivalent to #taint.
|
729
|
-
#
|
730
|
-
alias untrust taint
|
731
|
-
|
732
|
-
# Returns true if the object is tainted.
|
733
|
-
#
|
734
|
-
# See #taint for more information.
|
735
|
-
#
|
736
|
-
def tainted?: () -> bool
|
737
|
-
|
738
|
-
# Deprecated method that is equivalent to #tainted?.
|
739
|
-
#
|
740
|
-
alias untrusted? tainted?
|
741
|
-
|
742
|
-
# Yields self to the block, and then returns self. The primary purpose of this
|
743
|
-
# method is to "tap into" a method chain, in order to perform operations on
|
744
|
-
# intermediate results within the chain.
|
745
|
-
#
|
746
|
-
# (1..10) .tap {|x| puts "original: #{x}" }
|
747
|
-
# .to_a .tap {|x| puts "array: #{x}" }
|
748
|
-
# .select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
|
749
|
-
# .map {|x| x*x } .tap {|x| puts "squares: #{x}" }
|
750
|
-
#
|
751
|
-
def tap: () { (self) -> void } -> self
|
752
|
-
|
753
|
-
# Yields self to the block and returns the result of the block.
|
754
|
-
#
|
755
|
-
# 3.next.then {|x| x**x }.to_s #=> "256"
|
756
|
-
# "my string".yield_self {|s| s.upcase } #=> "MY STRING"
|
757
|
-
#
|
758
|
-
# Good usage for `yield_self` is value piping in method chains:
|
759
|
-
#
|
760
|
-
# require 'open-uri'
|
761
|
-
# require 'json'
|
762
|
-
#
|
763
|
-
# construct_url(arguments).
|
764
|
-
# yield_self {|url| open(url).read }.
|
765
|
-
# yield_self {|response| JSON.parse(response) }
|
766
|
-
#
|
767
|
-
# When called without block, the method returns `Enumerator`, which can be used,
|
768
|
-
# for example, for conditional circuit-breaking:
|
769
|
-
#
|
770
|
-
# # meets condition, no-op
|
771
|
-
# 1.yield_self.detect(&:odd?) # => 1
|
772
|
-
# # does not meet condition, drop value
|
773
|
-
# 2.yield_self.detect(&:odd?) # => nil
|
774
|
-
#
|
775
|
-
def `yield_self`: [X] () { (self) -> X } -> X
|
776
|
-
| () -> Enumerator[self, untyped]
|
777
|
-
|
778
|
-
# Returns a string representing *obj*. The default `to_s` prints the object's
|
779
|
-
# class and an encoding of the object id. As a special case, the top-level
|
780
|
-
# object that is the initial execution context of Ruby programs returns
|
781
|
-
# ``main''.
|
782
|
-
#
|
783
|
-
def to_s: () -> String
|
784
|
-
|
785
|
-
# Removes the tainted mark from the object.
|
786
|
-
#
|
787
|
-
# See #taint for more information.
|
788
|
-
#
|
789
|
-
def untaint: () -> self
|
790
|
-
|
791
|
-
# Deprecated method that is equivalent to #untaint.
|
792
|
-
#
|
793
|
-
alias trust untaint
|
794
|
-
|
795
|
-
# Yields self to the block and returns the result of the block.
|
796
|
-
#
|
797
|
-
# 3.next.then {|x| x**x }.to_s #=> "256"
|
798
|
-
# "my string".yield_self {|s| s.upcase } #=> "MY STRING"
|
799
|
-
#
|
800
|
-
# Good usage for `yield_self` is value piping in method chains:
|
801
|
-
#
|
802
|
-
# require 'open-uri'
|
803
|
-
# require 'json'
|
804
|
-
#
|
805
|
-
# construct_url(arguments).
|
806
|
-
# yield_self {|url| open(url).read }.
|
807
|
-
# yield_self {|response| JSON.parse(response) }
|
808
|
-
#
|
809
|
-
# When called without block, the method returns `Enumerator`, which can be used,
|
810
|
-
# for example, for conditional circuit-breaking:
|
811
|
-
#
|
812
|
-
# # meets condition, no-op
|
813
|
-
# 1.yield_self.detect(&:odd?) # => 1
|
814
|
-
# # does not meet condition, drop value
|
815
|
-
# 2.yield_self.detect(&:odd?) # => nil
|
816
|
-
#
|
817
|
-
alias then yield_self
|
818
|
-
end
|
819
|
-
|
820
|
-
interface _Writeable
|
821
|
-
def write: (untyped) -> void
|
822
|
-
end
|
823
|
-
|
824
|
-
type Object::name = Symbol | String
|