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,290 +0,0 @@
|
|
1
|
-
# Document-class: TracePoint
|
2
|
-
#
|
3
|
-
# A class that provides the functionality of Kernel#set_trace_func in a nice
|
4
|
-
# Object-Oriented API.
|
5
|
-
#
|
6
|
-
# ## Example
|
7
|
-
#
|
8
|
-
# We can use TracePoint to gather information specifically for exceptions:
|
9
|
-
#
|
10
|
-
# trace = TracePoint.new(:raise) do |tp|
|
11
|
-
# p [tp.lineno, tp.event, tp.raised_exception]
|
12
|
-
# end
|
13
|
-
# #=> #<TracePoint:disabled>
|
14
|
-
#
|
15
|
-
# trace.enable
|
16
|
-
# #=> false
|
17
|
-
#
|
18
|
-
# 0 / 0
|
19
|
-
# #=> [5, :raise, #<ZeroDivisionError: divided by 0>]
|
20
|
-
#
|
21
|
-
# ## Events
|
22
|
-
#
|
23
|
-
# If you don't specify the type of events you want to listen for, TracePoint
|
24
|
-
# will include all available events.
|
25
|
-
#
|
26
|
-
# **Note** do not depend on current event set, as this list is subject to
|
27
|
-
# change. Instead, it is recommended you specify the type of events you want to
|
28
|
-
# use.
|
29
|
-
#
|
30
|
-
# To filter what is traced, you can pass any of the following as `events`:
|
31
|
-
#
|
32
|
-
# `:line`
|
33
|
-
# : execute code on a new line
|
34
|
-
# `:class`
|
35
|
-
# : start a class or module definition
|
36
|
-
# `:end`
|
37
|
-
# : finish a class or module definition
|
38
|
-
# `:call`
|
39
|
-
# : call a Ruby method
|
40
|
-
# `:return`
|
41
|
-
# : return from a Ruby method
|
42
|
-
# `:c_call`
|
43
|
-
# : call a C-language routine
|
44
|
-
# `:c_return`
|
45
|
-
# : return from a C-language routine
|
46
|
-
# `:raise`
|
47
|
-
# : raise an exception
|
48
|
-
# `:b_call`
|
49
|
-
# : event hook at block entry
|
50
|
-
# `:b_return`
|
51
|
-
# : event hook at block ending
|
52
|
-
# `:thread_begin`
|
53
|
-
# : event hook at thread beginning
|
54
|
-
# `:thread_end`
|
55
|
-
# : event hook at thread ending
|
56
|
-
# `:fiber_switch`
|
57
|
-
# : event hook at fiber switch
|
58
|
-
# `:script_compiled`
|
59
|
-
# : new Ruby code compiled (with `eval`, `load` or `require`)
|
60
|
-
#
|
61
|
-
#
|
62
|
-
class TracePoint < Object
|
63
|
-
# Returns a new TracePoint object, not enabled by default.
|
64
|
-
#
|
65
|
-
# Next, in order to activate the trace, you must use TracePoint#enable
|
66
|
-
#
|
67
|
-
# trace = TracePoint.new(:call) do |tp|
|
68
|
-
# p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
|
69
|
-
# end
|
70
|
-
# #=> #<TracePoint:disabled>
|
71
|
-
#
|
72
|
-
# trace.enable
|
73
|
-
# #=> false
|
74
|
-
#
|
75
|
-
# puts "Hello, TracePoint!"
|
76
|
-
# # ...
|
77
|
-
# # [48, IRB::Notifier::AbstractNotifier, :printf, :call]
|
78
|
-
# # ...
|
79
|
-
#
|
80
|
-
# When you want to deactivate the trace, you must use TracePoint#disable
|
81
|
-
#
|
82
|
-
# trace.disable
|
83
|
-
#
|
84
|
-
# See TracePoint@Events for possible events and more information.
|
85
|
-
#
|
86
|
-
# A block must be given, otherwise an ArgumentError is raised.
|
87
|
-
#
|
88
|
-
# If the trace method isn't included in the given events filter, a RuntimeError
|
89
|
-
# is raised.
|
90
|
-
#
|
91
|
-
# TracePoint.trace(:line) do |tp|
|
92
|
-
# p tp.raised_exception
|
93
|
-
# end
|
94
|
-
# #=> RuntimeError: 'raised_exception' not supported by this event
|
95
|
-
#
|
96
|
-
# If the trace method is called outside block, a RuntimeError is raised.
|
97
|
-
#
|
98
|
-
# TracePoint.trace(:line) do |tp|
|
99
|
-
# $tp = tp
|
100
|
-
# end
|
101
|
-
# $tp.lineno #=> access from outside (RuntimeError)
|
102
|
-
#
|
103
|
-
# Access from other threads is also forbidden.
|
104
|
-
#
|
105
|
-
def initialize: (*Symbol events) { (TracePoint tp) -> void } -> void
|
106
|
-
|
107
|
-
# Returns internal information of TracePoint.
|
108
|
-
#
|
109
|
-
# The contents of the returned value are implementation specific. It may be
|
110
|
-
# changed in future.
|
111
|
-
#
|
112
|
-
# This method is only for debugging TracePoint itself.
|
113
|
-
#
|
114
|
-
def self.stat: () -> untyped
|
115
|
-
|
116
|
-
# Document-method: trace
|
117
|
-
#
|
118
|
-
# A convenience method for TracePoint.new, that activates the trace
|
119
|
-
# automatically.
|
120
|
-
#
|
121
|
-
# trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] }
|
122
|
-
# #=> #<TracePoint:enabled>
|
123
|
-
#
|
124
|
-
# trace.enabled? #=> true
|
125
|
-
#
|
126
|
-
def self.trace: (*Symbol events) { (TracePoint tp) -> void } -> TracePoint
|
127
|
-
|
128
|
-
# Return the generated binding object from event
|
129
|
-
#
|
130
|
-
def binding: () -> Binding
|
131
|
-
|
132
|
-
# Return the called name of the method being called
|
133
|
-
#
|
134
|
-
def callee_id: () -> Symbol
|
135
|
-
|
136
|
-
# Return class or module of the method being called.
|
137
|
-
#
|
138
|
-
# class C; def foo; end; end
|
139
|
-
# trace = TracePoint.new(:call) do |tp|
|
140
|
-
# p tp.defined_class #=> C
|
141
|
-
# end.enable do
|
142
|
-
# C.new.foo
|
143
|
-
# end
|
144
|
-
#
|
145
|
-
# If method is defined by a module, then that module is returned.
|
146
|
-
#
|
147
|
-
# module M; def foo; end; end
|
148
|
-
# class C; include M; end;
|
149
|
-
# trace = TracePoint.new(:call) do |tp|
|
150
|
-
# p tp.defined_class #=> M
|
151
|
-
# end.enable do
|
152
|
-
# C.new.foo
|
153
|
-
# end
|
154
|
-
#
|
155
|
-
# **Note:** #defined_class returns singleton class.
|
156
|
-
#
|
157
|
-
# 6th block parameter of Kernel#set_trace_func passes original class of attached
|
158
|
-
# by singleton class.
|
159
|
-
#
|
160
|
-
# **This is a difference between Kernel#set_trace_func and TracePoint.**
|
161
|
-
#
|
162
|
-
# class C; def self.foo; end; end
|
163
|
-
# trace = TracePoint.new(:call) do |tp|
|
164
|
-
# p tp.defined_class #=> #<Class:C>
|
165
|
-
# end.enable do
|
166
|
-
# C.foo
|
167
|
-
# end
|
168
|
-
#
|
169
|
-
def defined_class: () -> Module
|
170
|
-
|
171
|
-
# Deactivates the trace
|
172
|
-
#
|
173
|
-
# Return true if trace was enabled. Return false if trace was disabled.
|
174
|
-
#
|
175
|
-
# trace.enabled? #=> true
|
176
|
-
# trace.disable #=> true (previous status)
|
177
|
-
# trace.enabled? #=> false
|
178
|
-
# trace.disable #=> false
|
179
|
-
#
|
180
|
-
# If a block is given, the trace will only be disable within the scope of the
|
181
|
-
# block.
|
182
|
-
#
|
183
|
-
# trace.enabled?
|
184
|
-
# #=> true
|
185
|
-
#
|
186
|
-
# trace.disable do
|
187
|
-
# trace.enabled?
|
188
|
-
# # only disabled for this block
|
189
|
-
# end
|
190
|
-
#
|
191
|
-
# trace.enabled?
|
192
|
-
# #=> true
|
193
|
-
#
|
194
|
-
# Note: You cannot access event hooks within the block.
|
195
|
-
#
|
196
|
-
# trace.disable { p tp.lineno }
|
197
|
-
# #=> RuntimeError: access from outside
|
198
|
-
#
|
199
|
-
def disable: () -> bool
|
200
|
-
| () { () -> void } -> void
|
201
|
-
|
202
|
-
# Activates the trace.
|
203
|
-
#
|
204
|
-
# Returns `true` if trace was enabled. Returns `false` if trace was disabled.
|
205
|
-
#
|
206
|
-
# trace.enabled? #=> false
|
207
|
-
# trace.enable #=> false (previous state)
|
208
|
-
# # trace is enabled
|
209
|
-
# trace.enabled? #=> true
|
210
|
-
# trace.enable #=> true (previous state)
|
211
|
-
# # trace is still enabled
|
212
|
-
#
|
213
|
-
# If a block is given, the trace will only be enabled within the scope of the
|
214
|
-
# block.
|
215
|
-
#
|
216
|
-
# trace.enabled?
|
217
|
-
# #=> false
|
218
|
-
#
|
219
|
-
# trace.enable do
|
220
|
-
# trace.enabled?
|
221
|
-
# # only enabled for this block
|
222
|
-
# end
|
223
|
-
#
|
224
|
-
# trace.enabled?
|
225
|
-
# #=> false
|
226
|
-
#
|
227
|
-
# `target`, `target_line` and `target_thread` parameters are used to limit
|
228
|
-
# tracing only to specified code objects. `target` should be a code object for
|
229
|
-
# which RubyVM::InstructionSequence.of will return an instruction sequence.
|
230
|
-
#
|
231
|
-
# t = TracePoint.new(:line) { |tp| p tp }
|
232
|
-
#
|
233
|
-
# def m1
|
234
|
-
# p 1
|
235
|
-
# end
|
236
|
-
#
|
237
|
-
# def m2
|
238
|
-
# p 2
|
239
|
-
# end
|
240
|
-
#
|
241
|
-
# t.enable(target: method(:m1))
|
242
|
-
#
|
243
|
-
# m1
|
244
|
-
# # prints #<TracePoint:line@test.rb:5 in `m1'>
|
245
|
-
# m2
|
246
|
-
# # prints nothing
|
247
|
-
#
|
248
|
-
# Note: You cannot access event hooks within the `enable` block.
|
249
|
-
#
|
250
|
-
# trace.enable { p tp.lineno }
|
251
|
-
# #=> RuntimeError: access from outside
|
252
|
-
#
|
253
|
-
def enable: () -> bool
|
254
|
-
| () { () -> void } -> void
|
255
|
-
|
256
|
-
# The current status of the trace
|
257
|
-
#
|
258
|
-
def enabled?: () -> bool
|
259
|
-
|
260
|
-
# Return a string containing a human-readable TracePoint status.
|
261
|
-
#
|
262
|
-
def inspect: () -> String
|
263
|
-
|
264
|
-
# Line number of the event
|
265
|
-
#
|
266
|
-
def lineno: () -> Integer
|
267
|
-
|
268
|
-
# Return the name at the definition of the method being called
|
269
|
-
#
|
270
|
-
def method_id: () -> Symbol
|
271
|
-
|
272
|
-
# Path of the file being run
|
273
|
-
#
|
274
|
-
def path: () -> String
|
275
|
-
|
276
|
-
# Value from exception raised on the `:raise` event
|
277
|
-
#
|
278
|
-
def raised_exception: () -> untyped
|
279
|
-
|
280
|
-
# Return value from `:return`, `c_return`, and `b_return` event
|
281
|
-
#
|
282
|
-
def return_value: () -> untyped
|
283
|
-
|
284
|
-
# Return the trace object during event
|
285
|
-
#
|
286
|
-
# Same as TracePoint#binding:
|
287
|
-
# trace.binding.eval('self')
|
288
|
-
#
|
289
|
-
def `self`: () -> Binding
|
290
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# The global value `true` is the only instance of class TrueClass and represents
|
2
|
-
# a logically true value in boolean expressions. The class provides operators
|
3
|
-
# allowing `true` to be used in logical expressions.
|
4
|
-
#
|
5
|
-
class TrueClass
|
6
|
-
public
|
7
|
-
|
8
|
-
def !: () -> bool
|
9
|
-
|
10
|
-
# And---Returns `false` if *obj* is `nil` or `false`, `true` otherwise.
|
11
|
-
#
|
12
|
-
def &: (nil) -> false
|
13
|
-
| (false) -> false
|
14
|
-
| (untyped obj) -> bool
|
15
|
-
|
16
|
-
# Case Equality -- For class Object, effectively the same as calling `#==`, but
|
17
|
-
# typically overridden by descendants to provide meaningful semantics in `case`
|
18
|
-
# statements.
|
19
|
-
#
|
20
|
-
def ===: (true) -> true
|
21
|
-
| (untyped obj) -> bool
|
22
|
-
|
23
|
-
# Exclusive Or---Returns `true` if *obj* is `nil` or `false`, `false` otherwise.
|
24
|
-
#
|
25
|
-
def ^: (nil) -> true
|
26
|
-
| (false) -> true
|
27
|
-
| (untyped obj) -> bool
|
28
|
-
|
29
|
-
alias inspect to_s
|
30
|
-
|
31
|
-
# The string representation of `true` is "true".
|
32
|
-
#
|
33
|
-
def to_s: () -> "true"
|
34
|
-
|
35
|
-
# Or---Returns `true`. As *obj* is an argument to a method call, it is always
|
36
|
-
# evaluated; there is no short-circuit evaluation in this case.
|
37
|
-
#
|
38
|
-
# true | puts("or")
|
39
|
-
# true || puts("logical or")
|
40
|
-
#
|
41
|
-
# *produces:*
|
42
|
-
#
|
43
|
-
# or
|
44
|
-
#
|
45
|
-
def |: (bool obj) -> bool
|
46
|
-
end
|
@@ -1,153 +0,0 @@
|
|
1
|
-
# Ruby supports two forms of objectified methods. Class Method is used to
|
2
|
-
# represent methods that are associated with a particular object: these method
|
3
|
-
# objects are bound to that object. Bound method objects for an object can be
|
4
|
-
# created using Object#method.
|
5
|
-
#
|
6
|
-
# Ruby also supports unbound methods; methods objects that are not associated
|
7
|
-
# with a particular object. These can be created either by calling
|
8
|
-
# Module#instance_method or by calling #unbind on a bound method object. The
|
9
|
-
# result of both of these is an UnboundMethod object.
|
10
|
-
#
|
11
|
-
# Unbound methods can only be called after they are bound to an object. That
|
12
|
-
# object must be a kind_of? the method's original class.
|
13
|
-
#
|
14
|
-
# class Square
|
15
|
-
# def area
|
16
|
-
# @side * @side
|
17
|
-
# end
|
18
|
-
# def initialize(side)
|
19
|
-
# @side = side
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# area_un = Square.instance_method(:area)
|
24
|
-
#
|
25
|
-
# s = Square.new(12)
|
26
|
-
# area = area_un.bind(s)
|
27
|
-
# area.call #=> 144
|
28
|
-
#
|
29
|
-
# Unbound methods are a reference to the method at the time it was objectified:
|
30
|
-
# subsequent changes to the underlying class will not affect the unbound method.
|
31
|
-
#
|
32
|
-
# class Test
|
33
|
-
# def test
|
34
|
-
# :original
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
# um = Test.instance_method(:test)
|
38
|
-
# class Test
|
39
|
-
# def test
|
40
|
-
# :modified
|
41
|
-
# end
|
42
|
-
# end
|
43
|
-
# t = Test.new
|
44
|
-
# t.test #=> :modified
|
45
|
-
# um.bind(t).call #=> :original
|
46
|
-
#
|
47
|
-
class UnboundMethod
|
48
|
-
# Returns an indication of the number of arguments accepted by a method. Returns
|
49
|
-
# a nonnegative integer for methods that take a fixed number of arguments. For
|
50
|
-
# Ruby methods that take a variable number of arguments, returns -n-1, where n
|
51
|
-
# is the number of required arguments. Keyword arguments will be considered as a
|
52
|
-
# single additional argument, that argument being mandatory if any keyword
|
53
|
-
# argument is mandatory. For methods written in C, returns -1 if the call takes
|
54
|
-
# a variable number of arguments.
|
55
|
-
#
|
56
|
-
# class C
|
57
|
-
# def one; end
|
58
|
-
# def two(a); end
|
59
|
-
# def three(*a); end
|
60
|
-
# def four(a, b); end
|
61
|
-
# def five(a, b, *c); end
|
62
|
-
# def six(a, b, *c, &d); end
|
63
|
-
# def seven(a, b, x:0); end
|
64
|
-
# def eight(x:, y:); end
|
65
|
-
# def nine(x:, y:, **z); end
|
66
|
-
# def ten(*a, x:, y:); end
|
67
|
-
# end
|
68
|
-
# c = C.new
|
69
|
-
# c.method(:one).arity #=> 0
|
70
|
-
# c.method(:two).arity #=> 1
|
71
|
-
# c.method(:three).arity #=> -1
|
72
|
-
# c.method(:four).arity #=> 2
|
73
|
-
# c.method(:five).arity #=> -3
|
74
|
-
# c.method(:six).arity #=> -3
|
75
|
-
# c.method(:seven).arity #=> -3
|
76
|
-
# c.method(:eight).arity #=> 1
|
77
|
-
# c.method(:nine).arity #=> 1
|
78
|
-
# c.method(:ten).arity #=> -2
|
79
|
-
#
|
80
|
-
# "cat".method(:size).arity #=> 0
|
81
|
-
# "cat".method(:replace).arity #=> 1
|
82
|
-
# "cat".method(:squeeze).arity #=> -1
|
83
|
-
# "cat".method(:count).arity #=> -1
|
84
|
-
#
|
85
|
-
def arity: () -> Integer
|
86
|
-
|
87
|
-
# Bind *umeth* to *obj*. If Klass was the class from which *umeth* was obtained,
|
88
|
-
# `obj.kind_of?(Klass)` must be true.
|
89
|
-
#
|
90
|
-
# class A
|
91
|
-
# def test
|
92
|
-
# puts "In test, class = #{self.class}"
|
93
|
-
# end
|
94
|
-
# end
|
95
|
-
# class B < A
|
96
|
-
# end
|
97
|
-
# class C < B
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# um = B.instance_method(:test)
|
101
|
-
# bm = um.bind(C.new)
|
102
|
-
# bm.call
|
103
|
-
# bm = um.bind(B.new)
|
104
|
-
# bm.call
|
105
|
-
# bm = um.bind(A.new)
|
106
|
-
# bm.call
|
107
|
-
#
|
108
|
-
# *produces:*
|
109
|
-
#
|
110
|
-
# In test, class = C
|
111
|
-
# In test, class = B
|
112
|
-
# prog.rb:16:in `bind': bind argument must be an instance of B (TypeError)
|
113
|
-
# from prog.rb:16
|
114
|
-
#
|
115
|
-
def bind: (untyped obj) -> Method
|
116
|
-
|
117
|
-
# Returns the name of the method.
|
118
|
-
#
|
119
|
-
def name: () -> Symbol
|
120
|
-
|
121
|
-
# Returns the class or module that defines the method. See also Method#receiver.
|
122
|
-
#
|
123
|
-
# (1..3).method(:map).owner #=> Enumerable
|
124
|
-
#
|
125
|
-
def owner: () -> Module
|
126
|
-
|
127
|
-
# Returns the parameter information of this method.
|
128
|
-
#
|
129
|
-
# def foo(bar); end
|
130
|
-
# method(:foo).parameters #=> [[:req, :bar]]
|
131
|
-
#
|
132
|
-
# def foo(bar, baz, bat, &blk); end
|
133
|
-
# method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:req, :bat], [:block, :blk]]
|
134
|
-
#
|
135
|
-
# def foo(bar, *args); end
|
136
|
-
# method(:foo).parameters #=> [[:req, :bar], [:rest, :args]]
|
137
|
-
#
|
138
|
-
# def foo(bar, baz, *args, &blk); end
|
139
|
-
# method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:rest, :args], [:block, :blk]]
|
140
|
-
#
|
141
|
-
def parameters: () -> ::Array[[ Symbol, Symbol ]]
|
142
|
-
| () -> ::Array[[ Symbol ]]
|
143
|
-
|
144
|
-
# Returns the Ruby source filename and line number containing this method or nil
|
145
|
-
# if this method was not defined in Ruby (i.e. native).
|
146
|
-
#
|
147
|
-
def source_location: () -> [ String, Integer ]?
|
148
|
-
|
149
|
-
# Returns a Method of superclass which would be called when super is used or nil
|
150
|
-
# if there is no method on superclass.
|
151
|
-
#
|
152
|
-
def super_method: () -> UnboundMethod?
|
153
|
-
end
|