rbs 4.0.0.dev.4 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +14 -14
- data/.github/workflows/bundle-update.yml +60 -0
- data/.github/workflows/c-check.yml +18 -11
- data/.github/workflows/comments.yml +5 -3
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/ruby.yml +27 -34
- data/.github/workflows/rust.yml +95 -0
- data/.github/workflows/typecheck.yml +2 -2
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +323 -0
- data/README.md +1 -1
- data/Rakefile +43 -33
- data/Steepfile +1 -0
- data/config.yml +426 -24
- data/core/array.rbs +307 -227
- data/core/basic_object.rbs +9 -8
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +2 -2
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +55 -34
- data/core/complex.rbs +104 -78
- data/core/dir.rbs +61 -49
- data/core/encoding.rbs +12 -15
- data/core/enumerable.rbs +179 -87
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +65 -2
- data/core/errno.rbs +11 -2
- data/core/errors.rbs +58 -29
- data/core/exception.rbs +13 -13
- data/core/fiber.rbs +74 -54
- data/core/file.rbs +280 -177
- data/core/file_test.rbs +3 -3
- data/core/float.rbs +257 -92
- data/core/gc.rbs +425 -281
- data/core/hash.rbs +1045 -739
- data/core/integer.rbs +135 -137
- data/core/io/buffer.rbs +53 -42
- data/core/io/wait.rbs +13 -35
- data/core/io.rbs +192 -144
- data/core/kernel.rbs +216 -155
- data/core/marshal.rbs +4 -4
- data/core/match_data.rbs +15 -13
- data/core/math.rbs +107 -66
- data/core/method.rbs +69 -33
- data/core/module.rbs +244 -106
- data/core/nil_class.rbs +7 -6
- data/core/numeric.rbs +74 -63
- data/core/object.rbs +9 -11
- data/core/object_space.rbs +30 -23
- data/core/pathname.rbs +1322 -0
- data/core/proc.rbs +95 -58
- data/core/process.rbs +222 -202
- data/core/ractor.rbs +371 -515
- data/core/random.rbs +21 -3
- data/core/range.rbs +159 -57
- data/core/rational.rbs +60 -89
- data/core/rbs/unnamed/argf.rbs +60 -53
- data/core/rbs/unnamed/env_class.rbs +19 -14
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +11 -118
- data/core/regexp.rbs +258 -214
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +38 -34
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +4 -71
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +16 -82
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +490 -360
- data/core/signal.rbs +26 -16
- data/core/string.rbs +3234 -1285
- data/core/struct.rbs +27 -26
- data/core/symbol.rbs +41 -34
- data/core/thread.rbs +135 -67
- data/core/time.rbs +81 -50
- data/core/trace_point.rbs +41 -35
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +24 -16
- data/core/warning.rbs +7 -7
- data/docs/aliases.md +79 -0
- data/docs/collection.md +3 -3
- data/docs/config.md +171 -0
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/inline.md +576 -0
- data/docs/sigs.md +3 -3
- data/docs/syntax.md +46 -16
- data/docs/type_fingerprint.md +21 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +544 -116
- data/ext/rbs_extension/ast_translation.h +3 -0
- data/ext/rbs_extension/class_constants.c +16 -2
- data/ext/rbs_extension/class_constants.h +8 -0
- data/ext/rbs_extension/extconf.rb +5 -1
- data/ext/rbs_extension/legacy_location.c +33 -56
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +44 -35
- data/include/rbs/ast.h +448 -173
- data/include/rbs/defines.h +27 -0
- data/include/rbs/lexer.h +30 -11
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +6 -6
- data/include/rbs/string.h +0 -2
- data/include/rbs/util/rbs_allocator.h +34 -13
- data/include/rbs/util/rbs_assert.h +12 -1
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs/util/rbs_encoding.h +2 -0
- data/include/rbs/util/rbs_unescape.h +2 -1
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +10 -10
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +293 -3
- data/lib/rbs/ast/ruby/comment_block.rb +24 -0
- data/lib/rbs/ast/ruby/declarations.rb +198 -3
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
- data/lib/rbs/ast/ruby/members.rb +532 -22
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +20 -15
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +38 -106
- data/lib/rbs/cli.rb +52 -19
- data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
- data/lib/rbs/definition_builder/method_builder.rb +20 -0
- data/lib/rbs/definition_builder.rb +147 -25
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment.rb +227 -74
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/errors.rb +27 -18
- data/lib/rbs/inline_parser.rb +342 -6
- data/lib/rbs/location_aux.rb +1 -1
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/parser_aux.rb +20 -7
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +3 -28
- data/lib/rbs/prototype/rbi.rb +3 -20
- data/lib/rbs/prototype/runtime.rb +8 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +116 -38
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +19 -2
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +88 -78
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -2
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +4 -3
- data/rust/.gitignore +1 -0
- data/rust/Cargo.lock +378 -0
- data/rust/Cargo.toml +7 -0
- data/rust/ruby-rbs/Cargo.toml +22 -0
- data/rust/ruby-rbs/build.rs +764 -0
- data/rust/ruby-rbs/examples/locations.rs +60 -0
- data/rust/ruby-rbs/src/lib.rs +1 -0
- data/rust/ruby-rbs/src/node/mod.rs +742 -0
- data/rust/ruby-rbs/tests/sanity.rs +47 -0
- data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
- data/rust/ruby-rbs-sys/Cargo.toml +23 -0
- data/rust/ruby-rbs-sys/build.rs +204 -0
- data/rust/ruby-rbs-sys/src/lib.rs +50 -0
- data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
- data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
- data/rust/ruby-rbs-sys/wrapper.h +1 -0
- data/schema/typeParam.json +17 -1
- data/sig/ast/ruby/annotations.rbs +315 -4
- data/sig/ast/ruby/comment_block.rbs +8 -0
- data/sig/ast/ruby/declarations.rbs +102 -4
- data/sig/ast/ruby/members.rbs +108 -2
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +12 -8
- data/sig/cli.rbs +18 -18
- data/sig/definition.rbs +6 -1
- data/sig/definition_builder.rbs +2 -0
- data/sig/environment.rbs +70 -12
- data/sig/errors.rbs +13 -14
- data/sig/inline_parser.rbs +39 -2
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -1
- data/sig/method_builder.rbs +3 -1
- data/sig/parser.rbs +31 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/resolver/type_name_resolver.rbs +35 -7
- data/sig/source.rbs +3 -3
- data/sig/type_param.rbs +13 -8
- data/sig/types.rbs +6 -7
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +410 -153
- data/src/lexer.c +1392 -1313
- data/src/lexer.re +3 -0
- data/src/lexstate.c +58 -37
- data/src/location.c +8 -48
- data/src/parser.c +977 -516
- data/src/string.c +0 -48
- data/src/util/rbs_allocator.c +89 -71
- data/src/util/rbs_assert.c +1 -1
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +10 -14
- data/src/util/rbs_encoding.c +4 -8
- data/src/util/rbs_unescape.c +56 -20
- data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +7 -4
- data/stdlib/date/0/date.rbs +92 -79
- data/stdlib/date/0/date_time.rbs +25 -24
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/digest/0/digest.rbs +110 -0
- data/stdlib/erb/0/erb.rbs +748 -347
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +158 -139
- data/stdlib/forwardable/0/forwardable.rbs +13 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +217 -136
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +162 -134
- data/stdlib/objspace/0/objspace.rbs +17 -34
- data/stdlib/open-uri/0/open-uri.rbs +48 -8
- data/stdlib/open3/0/open3.rbs +469 -10
- data/stdlib/openssl/0/openssl.rbs +475 -357
- data/stdlib/optparse/0/optparse.rbs +26 -17
- data/stdlib/pathname/0/pathname.rbs +11 -1381
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +65 -12
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -1
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +22 -19
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +7 -20
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/addrinfo.rbs +7 -7
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +23 -10
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +11 -3
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +1177 -85
- data/stdlib/strscan/0/string_scanner.rbs +27 -25
- data/stdlib/tempfile/0/tempfile.rbs +25 -21
- data/stdlib/time/0/time.rbs +8 -6
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +42 -20
- data/stdlib/uri/0/file.rbs +3 -3
- data/stdlib/uri/0/generic.rbs +26 -18
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_reader.rbs +6 -6
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +50 -6
data/core/marshal.rbs
CHANGED
|
@@ -147,7 +147,7 @@ module Marshal
|
|
|
147
147
|
# * anonymous Class/Module.
|
|
148
148
|
# * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket
|
|
149
149
|
# and so on)
|
|
150
|
-
# * an instance of MatchData,
|
|
150
|
+
# * an instance of MatchData, Method, UnboundMethod, Proc, Thread,
|
|
151
151
|
# ThreadGroup, Continuation
|
|
152
152
|
# * objects which define singleton methods
|
|
153
153
|
#
|
|
@@ -167,9 +167,9 @@ module Marshal
|
|
|
167
167
|
# Never pass untrusted data (including user supplied input) to this method.
|
|
168
168
|
# Please see the overview for further details.
|
|
169
169
|
#
|
|
170
|
-
# If the
|
|
171
|
-
# frozen. Note that it may lead to more efficient memory usage due to
|
|
172
|
-
# strings deduplication:
|
|
170
|
+
# If the <code>freeze: true</code> argument is passed, deserialized object would
|
|
171
|
+
# be deeply frozen. Note that it may lead to more efficient memory usage due to
|
|
172
|
+
# frozen strings deduplication:
|
|
173
173
|
#
|
|
174
174
|
# serialized = Marshal.dump(['value1', 'value2', 'value1', 'value2'])
|
|
175
175
|
#
|
data/core/match_data.rbs
CHANGED
|
@@ -34,14 +34,16 @@
|
|
|
34
34
|
# Parts of last MatchData (returned by Regexp.last_match) are also aliased as
|
|
35
35
|
# global variables:
|
|
36
36
|
#
|
|
37
|
-
# *
|
|
38
|
-
# *
|
|
39
|
-
# *
|
|
40
|
-
#
|
|
41
|
-
# *
|
|
42
|
-
# *
|
|
37
|
+
# * <code>$~</code> is Regexp.last_match;
|
|
38
|
+
# * <code>$&</code> is Regexp.last_match<code>[ 0 ]</code>;
|
|
39
|
+
# * <code>$1</code>, <code>$2</code>, and so on are Regexp.last_match<code>[ i
|
|
40
|
+
# ]</code> (captures by number);
|
|
41
|
+
# * <code>$`</code> is Regexp.last_match<code>.pre_match</code>;
|
|
42
|
+
# * <code>$'</code> is Regexp.last_match<code>.post_match</code>;
|
|
43
|
+
# * <code>$+</code> is Regexp.last_match<code>[ -1 ]</code> (the last
|
|
44
|
+
# capture).
|
|
43
45
|
#
|
|
44
|
-
# See also
|
|
46
|
+
# See also Regexp@Global+Variables.
|
|
45
47
|
#
|
|
46
48
|
class MatchData
|
|
47
49
|
type capture = String | Symbol | int
|
|
@@ -230,7 +232,7 @@ class MatchData
|
|
|
230
232
|
# rdoc-file=re.c
|
|
231
233
|
# - captures -> array
|
|
232
234
|
# -->
|
|
233
|
-
# Returns the array of captures, which are all matches except
|
|
235
|
+
# Returns the array of captures, which are all matches except <code>m[0]</code>:
|
|
234
236
|
#
|
|
235
237
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
|
236
238
|
# # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
|
|
@@ -242,7 +244,7 @@ class MatchData
|
|
|
242
244
|
def captures: () -> Array[String?]
|
|
243
245
|
|
|
244
246
|
# <!-- rdoc-file=re.c -->
|
|
245
|
-
# Returns the array of captures, which are all matches except
|
|
247
|
+
# Returns the array of captures, which are all matches except <code>m[0]</code>:
|
|
246
248
|
#
|
|
247
249
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
|
248
250
|
# # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
|
|
@@ -511,8 +513,8 @@ class MatchData
|
|
|
511
513
|
# - post_match -> str
|
|
512
514
|
# -->
|
|
513
515
|
# Returns the substring of the target string from the end of the first match in
|
|
514
|
-
# `self` (that is,
|
|
515
|
-
# global variable
|
|
516
|
+
# `self` (that is, <code>self[0]</code>) to the end of the string; equivalent to
|
|
517
|
+
# regexp global variable <code>$'</code>:
|
|
516
518
|
#
|
|
517
519
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
|
518
520
|
# # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
|
|
@@ -528,8 +530,8 @@ class MatchData
|
|
|
528
530
|
# - pre_match -> string
|
|
529
531
|
# -->
|
|
530
532
|
# Returns the substring of the target string from its beginning up to the first
|
|
531
|
-
# match in `self` (that is,
|
|
532
|
-
#
|
|
533
|
+
# match in `self` (that is, <code>self[0]</code>); equivalent to regexp global
|
|
534
|
+
# variable <code>$`</code>:
|
|
533
535
|
#
|
|
534
536
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
|
535
537
|
# # => #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
|
data/core/math.rbs
CHANGED
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
# because many such values are, in mathematics, of infinite precision, while in
|
|
42
42
|
# numerical computation the precision is finite.
|
|
43
43
|
#
|
|
44
|
-
# Thus, in mathematics,
|
|
45
|
-
#
|
|
44
|
+
# Thus, in mathematics, <em>cos(π/2)</em> is exactly zero, but in our
|
|
45
|
+
# computation <code>cos(PI/2)</code> is a number very close to zero:
|
|
46
46
|
#
|
|
47
47
|
# cos(PI/2) # => 6.123031769111886e-17
|
|
48
48
|
#
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
#
|
|
115
115
|
# #### Hypotenuse Function
|
|
116
116
|
#
|
|
117
|
-
# * ::hypot: Returns
|
|
117
|
+
# * ::hypot: Returns <code>sqrt(a**2 + b**2)</code> for the given `a` and `b`.
|
|
118
118
|
#
|
|
119
119
|
module Math
|
|
120
120
|
# <!-- rdoc-file=math.c -->
|
|
@@ -137,7 +137,7 @@ module Math
|
|
|
137
137
|
#
|
|
138
138
|
# Math.acos(42)
|
|
139
139
|
#
|
|
140
|
-
#
|
|
140
|
+
# <em>produces:</em>
|
|
141
141
|
#
|
|
142
142
|
# Math::DomainError: Numerical argument is out of domain - "acos"
|
|
143
143
|
#
|
|
@@ -155,8 +155,8 @@ module Math
|
|
|
155
155
|
# Returns the [arc
|
|
156
156
|
# cosine](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of `x`.
|
|
157
157
|
#
|
|
158
|
-
# * Domain:
|
|
159
|
-
# * Range:
|
|
158
|
+
# * Domain: <code>[-1, 1]</code>.
|
|
159
|
+
# * Range: <code>[0, PI]</code>.
|
|
160
160
|
#
|
|
161
161
|
# Examples:
|
|
162
162
|
#
|
|
@@ -173,8 +173,8 @@ module Math
|
|
|
173
173
|
# Returns the [inverse hyperbolic
|
|
174
174
|
# cosine](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`.
|
|
175
175
|
#
|
|
176
|
-
# * Domain:
|
|
177
|
-
# * Range:
|
|
176
|
+
# * Domain: <code>[1, INFINITY]</code>.
|
|
177
|
+
# * Range: <code>[0, INFINITY]</code>.
|
|
178
178
|
#
|
|
179
179
|
# Examples:
|
|
180
180
|
#
|
|
@@ -190,8 +190,8 @@ module Math
|
|
|
190
190
|
# Returns the [arc
|
|
191
191
|
# sine](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of `x`.
|
|
192
192
|
#
|
|
193
|
-
# * Domain:
|
|
194
|
-
# * Range:
|
|
193
|
+
# * Domain: <code>[-1, -1]</code>.
|
|
194
|
+
# * Range: <code>[-PI/2, PI/2]</code>.
|
|
195
195
|
#
|
|
196
196
|
# Examples:
|
|
197
197
|
#
|
|
@@ -208,8 +208,8 @@ module Math
|
|
|
208
208
|
# Returns the [inverse hyperbolic
|
|
209
209
|
# sine](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`.
|
|
210
210
|
#
|
|
211
|
-
# * Domain:
|
|
212
|
-
# * Range:
|
|
211
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
212
|
+
# * Range: <code>[-INFINITY, INFINITY]</code>.
|
|
213
213
|
#
|
|
214
214
|
# Examples:
|
|
215
215
|
#
|
|
@@ -227,8 +227,8 @@ module Math
|
|
|
227
227
|
# tangent](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) of
|
|
228
228
|
# `x`.
|
|
229
229
|
#
|
|
230
|
-
# * Domain:
|
|
231
|
-
# * Range:
|
|
230
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
231
|
+
# * Range: <code>[-PI/2, PI/2] </code>.
|
|
232
232
|
#
|
|
233
233
|
# Examples:
|
|
234
234
|
#
|
|
@@ -251,9 +251,9 @@ module Math
|
|
|
251
251
|
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
252
252
|
# _degrees).
|
|
253
253
|
#
|
|
254
|
-
# * Domain of `y`:
|
|
255
|
-
# * Domain of `x`:
|
|
256
|
-
# * Range:
|
|
254
|
+
# * Domain of `y`: <code>[-INFINITY, INFINITY]</code>.
|
|
255
|
+
# * Domain of `x`: <code>[-INFINITY, INFINITY]</code>.
|
|
256
|
+
# * Range: <code>[-PI, PI]</code>.
|
|
257
257
|
#
|
|
258
258
|
# Examples:
|
|
259
259
|
#
|
|
@@ -271,8 +271,8 @@ module Math
|
|
|
271
271
|
# Returns the [inverse hyperbolic
|
|
272
272
|
# tangent](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) of `x`.
|
|
273
273
|
#
|
|
274
|
-
# * Domain:
|
|
275
|
-
# * Range:
|
|
274
|
+
# * Domain: <code>[-1, 1]</code>.
|
|
275
|
+
# * Range: <code>[-INFINITY, INFINITY]</code>.
|
|
276
276
|
#
|
|
277
277
|
# Examples:
|
|
278
278
|
#
|
|
@@ -288,8 +288,8 @@ module Math
|
|
|
288
288
|
# -->
|
|
289
289
|
# Returns the [cube root](https://en.wikipedia.org/wiki/Cube_root) of `x`.
|
|
290
290
|
#
|
|
291
|
-
# * Domain:
|
|
292
|
-
# * Range:
|
|
291
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
292
|
+
# * Range: <code>[-INFINITY, INFINITY]</code>.
|
|
293
293
|
#
|
|
294
294
|
# Examples:
|
|
295
295
|
#
|
|
@@ -315,8 +315,8 @@ module Math
|
|
|
315
315
|
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
316
316
|
# _degrees).
|
|
317
317
|
#
|
|
318
|
-
# * Domain:
|
|
319
|
-
# * Range:
|
|
318
|
+
# * Domain: <code>(-INFINITY, INFINITY)</code>.
|
|
319
|
+
# * Range: <code>[-1.0, 1.0]</code>.
|
|
320
320
|
#
|
|
321
321
|
# Examples:
|
|
322
322
|
#
|
|
@@ -337,8 +337,8 @@ module Math
|
|
|
337
337
|
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
338
338
|
# _degrees).
|
|
339
339
|
#
|
|
340
|
-
# * Domain:
|
|
341
|
-
# * Range:
|
|
340
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
341
|
+
# * Range: <code>[1, INFINITY]</code>.
|
|
342
342
|
#
|
|
343
343
|
# Examples:
|
|
344
344
|
#
|
|
@@ -355,8 +355,8 @@ module Math
|
|
|
355
355
|
# Returns the value of the [Gauss error
|
|
356
356
|
# function](https://en.wikipedia.org/wiki/Error_function) for `x`.
|
|
357
357
|
#
|
|
358
|
-
# * Domain:
|
|
359
|
-
# * Range:
|
|
358
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
359
|
+
# * Range: <code>[-1, 1]</code>.
|
|
360
360
|
#
|
|
361
361
|
# Examples:
|
|
362
362
|
#
|
|
@@ -376,8 +376,8 @@ module Math
|
|
|
376
376
|
# function](https://en.wikipedia.org/wiki/Error_function#Complementary_error_fun
|
|
377
377
|
# ction) for `x`.
|
|
378
378
|
#
|
|
379
|
-
# * Domain:
|
|
380
|
-
# * Range:
|
|
379
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
380
|
+
# * Range: <code>[0, 2]</code>.
|
|
381
381
|
#
|
|
382
382
|
# Examples:
|
|
383
383
|
#
|
|
@@ -395,8 +395,8 @@ module Math
|
|
|
395
395
|
# -->
|
|
396
396
|
# Returns `e` raised to the `x` power.
|
|
397
397
|
#
|
|
398
|
-
# * Domain:
|
|
399
|
-
# * Range:
|
|
398
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
399
|
+
# * Range: <code>[0, INFINITY]</code>.
|
|
400
400
|
#
|
|
401
401
|
# Examples:
|
|
402
402
|
#
|
|
@@ -410,6 +410,27 @@ module Math
|
|
|
410
410
|
#
|
|
411
411
|
def self.exp: (double x) -> Float
|
|
412
412
|
|
|
413
|
+
# <!--
|
|
414
|
+
# rdoc-file=math.c
|
|
415
|
+
# - Math.expm1(x) -> float
|
|
416
|
+
# -->
|
|
417
|
+
# Returns "exp(x) - 1", `e` raised to the `x` power, minus 1.
|
|
418
|
+
#
|
|
419
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
420
|
+
# * Range: <code>[-1.0, INFINITY]</code>.
|
|
421
|
+
#
|
|
422
|
+
# Examples:
|
|
423
|
+
#
|
|
424
|
+
# expm1(-INFINITY) # => 0.0
|
|
425
|
+
# expm1(-1.0) # => -0.6321205588285577 # 1.0/E - 1
|
|
426
|
+
# expm1(0.0) # => 0.0
|
|
427
|
+
# expm1(0.5) # => 0.6487212707001282 # sqrt(E) - 1
|
|
428
|
+
# expm1(1.0) # => 1.718281828459045 # E - 1
|
|
429
|
+
# expm1(2.0) # => 6.38905609893065 # E**2 - 1
|
|
430
|
+
# expm1(INFINITY) # => Infinity
|
|
431
|
+
#
|
|
432
|
+
def self.expm1: (double x) -> Float
|
|
433
|
+
|
|
413
434
|
# <!--
|
|
414
435
|
# rdoc-file=math.c
|
|
415
436
|
# - Math.frexp(x) -> [fraction, exponent]
|
|
@@ -423,8 +444,8 @@ module Math
|
|
|
423
444
|
# binary64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format
|
|
424
445
|
# #IEEE_754_double-precision_binary_floating-point_format:_binary64).
|
|
425
446
|
#
|
|
426
|
-
# * Domain:
|
|
427
|
-
# * Range
|
|
447
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
448
|
+
# * Range <code>[-INFINITY, INFINITY]</code>.
|
|
428
449
|
#
|
|
429
450
|
# Examples:
|
|
430
451
|
#
|
|
@@ -447,8 +468,8 @@ module Math
|
|
|
447
468
|
# Returns the value of the [gamma
|
|
448
469
|
# function](https://en.wikipedia.org/wiki/Gamma_function) for `x`.
|
|
449
470
|
#
|
|
450
|
-
# * Domain:
|
|
451
|
-
# * Range:
|
|
471
|
+
# * Domain: <code>(-INFINITY, INFINITY]</code> excluding negative integers.
|
|
472
|
+
# * Range: <code>[-INFINITY, INFINITY]</code>.
|
|
452
473
|
#
|
|
453
474
|
# Examples:
|
|
454
475
|
#
|
|
@@ -470,12 +491,13 @@ module Math
|
|
|
470
491
|
# rdoc-file=math.c
|
|
471
492
|
# - Math.hypot(a, b) -> float
|
|
472
493
|
# -->
|
|
473
|
-
# Returns
|
|
474
|
-
# hypotenuse) of the right triangle whose other sides have lengths
|
|
494
|
+
# Returns <code>sqrt(a**2 + b**2)</code>, which is the length of the longest
|
|
495
|
+
# side `c` (the hypotenuse) of the right triangle whose other sides have lengths
|
|
496
|
+
# `a` and `b`.
|
|
475
497
|
#
|
|
476
|
-
# * Domain of `a`:
|
|
477
|
-
# * Domain of +ab:
|
|
478
|
-
# * Range:
|
|
498
|
+
# * Domain of `a`: <code>[-INFINITY, INFINITY]</code>.
|
|
499
|
+
# * Domain of +ab: <code>[-INFINITY, INFINITY]</code>.
|
|
500
|
+
# * Range: <code>[0, INFINITY]</code>.
|
|
479
501
|
#
|
|
480
502
|
# Examples:
|
|
481
503
|
#
|
|
@@ -485,8 +507,8 @@ module Math
|
|
|
485
507
|
# hypot(5.0, 12.0) # => 13.0
|
|
486
508
|
# hypot(1.0, sqrt(3.0)) # => 1.9999999999999998 # Near 2.0
|
|
487
509
|
#
|
|
488
|
-
# Note that if either argument is `INFINITY` or
|
|
489
|
-
# `Infinity`.
|
|
510
|
+
# Note that if either argument is `INFINITY` or <code>-INFINITY</code>, the
|
|
511
|
+
# result is `Infinity`.
|
|
490
512
|
#
|
|
491
513
|
def self.hypot: (double x, double y) -> Float
|
|
492
514
|
|
|
@@ -494,10 +516,11 @@ module Math
|
|
|
494
516
|
# rdoc-file=math.c
|
|
495
517
|
# - Math.ldexp(fraction, exponent) -> float
|
|
496
518
|
# -->
|
|
497
|
-
# Returns the value of
|
|
519
|
+
# Returns the value of <code>fraction * 2**exponent</code>.
|
|
498
520
|
#
|
|
499
|
-
# * Domain of `fraction`:
|
|
500
|
-
# * Domain of `exponent`:
|
|
521
|
+
# * Domain of `fraction`: <code>[0.0, 1.0)</code>.
|
|
522
|
+
# * Domain of `exponent`: <code>[0, 1024]</code> (larger values are equivalent
|
|
523
|
+
# to 1024).
|
|
501
524
|
#
|
|
502
525
|
# See [IEEE 754 double-precision binary floating-point format:
|
|
503
526
|
# binary64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format
|
|
@@ -525,12 +548,11 @@ module Math
|
|
|
525
548
|
#
|
|
526
549
|
# [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
|
|
527
550
|
#
|
|
528
|
-
# See [
|
|
529
|
-
# function](https://en.wikipedia.org/wiki/Gamma_function#
|
|
530
|
-
# .
|
|
551
|
+
# See [log gamma
|
|
552
|
+
# function](https://en.wikipedia.org/wiki/Gamma_function#Log-gamma_function).
|
|
531
553
|
#
|
|
532
|
-
# * Domain:
|
|
533
|
-
# * Range of first element:
|
|
554
|
+
# * Domain: <code>(-INFINITY, INFINITY]</code>.
|
|
555
|
+
# * Range of first element: <code>(-INFINITY, INFINITY]</code>.
|
|
534
556
|
# * Second element is -1 or 1.
|
|
535
557
|
#
|
|
536
558
|
# Examples:
|
|
@@ -564,8 +586,8 @@ module Math
|
|
|
564
586
|
# Returns the base `base` [logarithm](https://en.wikipedia.org/wiki/Logarithm)
|
|
565
587
|
# of `x`.
|
|
566
588
|
#
|
|
567
|
-
# * Domain:
|
|
568
|
-
# * Range:
|
|
589
|
+
# * Domain: <code>[0, INFINITY]</code>.
|
|
590
|
+
# * Range: <code>[-INFINITY, INFINITY)]</code>.
|
|
569
591
|
#
|
|
570
592
|
# Examples:
|
|
571
593
|
#
|
|
@@ -591,8 +613,8 @@ module Math
|
|
|
591
613
|
# Returns the base 10 [logarithm](https://en.wikipedia.org/wiki/Logarithm) of
|
|
592
614
|
# `x`.
|
|
593
615
|
#
|
|
594
|
-
# * Domain:
|
|
595
|
-
# * Range:
|
|
616
|
+
# * Domain: <code>[0, INFINITY]</code>.
|
|
617
|
+
# * Range: <code>[-INFINITY, INFINITY]</code>.
|
|
596
618
|
#
|
|
597
619
|
# Examples:
|
|
598
620
|
#
|
|
@@ -603,6 +625,25 @@ module Math
|
|
|
603
625
|
#
|
|
604
626
|
def self.log10: (double x) -> Float
|
|
605
627
|
|
|
628
|
+
# <!--
|
|
629
|
+
# rdoc-file=math.c
|
|
630
|
+
# - Math.log1p(x) -> float
|
|
631
|
+
# -->
|
|
632
|
+
# Returns "log(x + 1)", the base E
|
|
633
|
+
# [logarithm](https://en.wikipedia.org/wiki/Logarithm) of (`x` + 1).
|
|
634
|
+
#
|
|
635
|
+
# * Domain: <code>[-1, INFINITY]</code>.
|
|
636
|
+
# * Range: <code>[-INFINITY, INFINITY]</code>.
|
|
637
|
+
#
|
|
638
|
+
# Examples:
|
|
639
|
+
#
|
|
640
|
+
# log1p(-1.0) # => -Infinity
|
|
641
|
+
# log1p(0.0) # => 0.0
|
|
642
|
+
# log1p(E - 1) # => 1.0
|
|
643
|
+
# log1p(INFINITY) # => Infinity
|
|
644
|
+
#
|
|
645
|
+
def self.log1p: (double x) -> Float
|
|
646
|
+
|
|
606
647
|
# <!--
|
|
607
648
|
# rdoc-file=math.c
|
|
608
649
|
# - Math.log2(x) -> float
|
|
@@ -610,8 +651,8 @@ module Math
|
|
|
610
651
|
# Returns the base 2 [logarithm](https://en.wikipedia.org/wiki/Logarithm) of
|
|
611
652
|
# `x`.
|
|
612
653
|
#
|
|
613
|
-
# * Domain:
|
|
614
|
-
# * Range:
|
|
654
|
+
# * Domain: <code>[0, INFINITY]</code>.
|
|
655
|
+
# * Range: <code>[-INFINITY, INFINITY]</code>.
|
|
615
656
|
#
|
|
616
657
|
# Examples:
|
|
617
658
|
#
|
|
@@ -630,8 +671,8 @@ module Math
|
|
|
630
671
|
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
631
672
|
# _degrees).
|
|
632
673
|
#
|
|
633
|
-
# * Domain:
|
|
634
|
-
# * Range:
|
|
674
|
+
# * Domain: <code>(-INFINITY, INFINITY)</code>.
|
|
675
|
+
# * Range: <code>[-1.0, 1.0]</code>.
|
|
635
676
|
#
|
|
636
677
|
# Examples:
|
|
637
678
|
#
|
|
@@ -652,8 +693,8 @@ module Math
|
|
|
652
693
|
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
653
694
|
# _degrees).
|
|
654
695
|
#
|
|
655
|
-
# * Domain:
|
|
656
|
-
# * Range:
|
|
696
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
697
|
+
# * Range: <code>[-INFINITY, INFINITY]</code>.
|
|
657
698
|
#
|
|
658
699
|
# Examples:
|
|
659
700
|
#
|
|
@@ -670,8 +711,8 @@ module Math
|
|
|
670
711
|
# Returns the principal (non-negative) [square
|
|
671
712
|
# root](https://en.wikipedia.org/wiki/Square_root) of `x`.
|
|
672
713
|
#
|
|
673
|
-
# * Domain:
|
|
674
|
-
# * Range:
|
|
714
|
+
# * Domain: <code>[0, INFINITY]</code>.
|
|
715
|
+
# * Range: <code>[0, INFINITY]</code>.
|
|
675
716
|
#
|
|
676
717
|
# Examples:
|
|
677
718
|
#
|
|
@@ -694,8 +735,8 @@ module Math
|
|
|
694
735
|
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
695
736
|
# _degrees).
|
|
696
737
|
#
|
|
697
|
-
# * Domain:
|
|
698
|
-
# * Range:
|
|
738
|
+
# * Domain: <code>(-INFINITY, INFINITY)</code>.
|
|
739
|
+
# * Range: <code>(-INFINITY, INFINITY)</code>.
|
|
699
740
|
#
|
|
700
741
|
# Examples:
|
|
701
742
|
#
|
|
@@ -716,8 +757,8 @@ module Math
|
|
|
716
757
|
# [radians](https://en.wikipedia.org/wiki/Trigonometric_functions#Radians_versus
|
|
717
758
|
# _degrees).
|
|
718
759
|
#
|
|
719
|
-
# * Domain:
|
|
720
|
-
# * Range:
|
|
760
|
+
# * Domain: <code>[-INFINITY, INFINITY]</code>.
|
|
761
|
+
# * Range: <code>[-1, 1]</code>.
|
|
721
762
|
#
|
|
722
763
|
# Examples:
|
|
723
764
|
#
|
data/core/method.rbs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# <!-- rdoc-file=proc.c -->
|
|
2
|
-
# Method objects are created by Object#method, and are associated with a
|
|
2
|
+
# `Method` objects are created by Object#method, and are associated with a
|
|
3
3
|
# particular object (not just with a class). They may be used to invoke the
|
|
4
4
|
# method within the object, and as a block associated with an iterator. They
|
|
5
5
|
# may also be unbound from one object (creating an UnboundMethod) and bound to
|
|
@@ -54,8 +54,6 @@ class Method
|
|
|
54
54
|
#
|
|
55
55
|
def hash: () -> Integer
|
|
56
56
|
|
|
57
|
-
def dup: () -> self
|
|
58
|
-
|
|
59
57
|
# <!--
|
|
60
58
|
# rdoc-file=proc.c
|
|
61
59
|
# - meth.to_s -> string
|
|
@@ -76,12 +74,12 @@ class Method
|
|
|
76
74
|
# Net::HTTP.method(:get).inspect
|
|
77
75
|
# #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
|
|
78
76
|
#
|
|
79
|
-
#
|
|
80
|
-
# value).
|
|
77
|
+
# <code>...</code> in argument definition means argument is optional (has some
|
|
78
|
+
# default value).
|
|
81
79
|
#
|
|
82
80
|
# For methods defined in C (language core and extensions), location and argument
|
|
83
81
|
# names can't be extracted, and only generic information is provided in form of
|
|
84
|
-
#
|
|
82
|
+
# <code>*</code> (any number of arguments) or `_` (some positional argument).
|
|
85
83
|
#
|
|
86
84
|
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
|
87
85
|
# "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
|
|
@@ -104,12 +102,12 @@ class Method
|
|
|
104
102
|
# Net::HTTP.method(:get).inspect
|
|
105
103
|
# #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
|
|
106
104
|
#
|
|
107
|
-
#
|
|
108
|
-
# value).
|
|
105
|
+
# <code>...</code> in argument definition means argument is optional (has some
|
|
106
|
+
# default value).
|
|
109
107
|
#
|
|
110
108
|
# For methods defined in C (language core and extensions), location and argument
|
|
111
109
|
# names can't be extracted, and only generic information is provided in form of
|
|
112
|
-
#
|
|
110
|
+
# <code>*</code> (any number of arguments) or `_` (some positional argument).
|
|
113
111
|
#
|
|
114
112
|
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
|
115
113
|
# "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
|
|
@@ -126,7 +124,9 @@ class Method
|
|
|
126
124
|
|
|
127
125
|
# <!--
|
|
128
126
|
# rdoc-file=proc.c
|
|
129
|
-
# - meth.call(args, ...)
|
|
127
|
+
# - meth.call(args, ...) -> obj
|
|
128
|
+
# - meth[args, ...] -> obj
|
|
129
|
+
# - method === obj -> result_of_method
|
|
130
130
|
# -->
|
|
131
131
|
# Invokes the *meth* with the specified arguments, returning the method's return
|
|
132
132
|
# value.
|
|
@@ -135,23 +135,32 @@ class Method
|
|
|
135
135
|
# m.call(3) #=> 15
|
|
136
136
|
# m.call(20) #=> 32
|
|
137
137
|
#
|
|
138
|
+
# Using Method#=== allows a method object to be the target of a `when` clause in
|
|
139
|
+
# a case statement.
|
|
140
|
+
#
|
|
141
|
+
# require 'prime'
|
|
142
|
+
#
|
|
143
|
+
# case 1373
|
|
144
|
+
# when Prime.method(:prime?)
|
|
145
|
+
# # ...
|
|
146
|
+
# end
|
|
147
|
+
#
|
|
138
148
|
def call: (?) -> untyped
|
|
139
149
|
|
|
140
150
|
# <!--
|
|
141
151
|
# rdoc-file=proc.c
|
|
142
|
-
# -
|
|
152
|
+
# - self << g -> a_proc
|
|
143
153
|
# -->
|
|
144
|
-
# Returns a proc that is the composition of
|
|
145
|
-
# returned proc takes a variable number of arguments, calls *g* with them then
|
|
146
|
-
# calls this method with the result.
|
|
154
|
+
# Returns a proc that is the composition of the given `g` and this method.
|
|
147
155
|
#
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
156
|
+
# The returned proc takes a variable number of arguments. It first calls `g`
|
|
157
|
+
# with the arguments, then calls `self` with the return value of `g`.
|
|
158
|
+
#
|
|
159
|
+
# def f(ary) = ary << 'in f'
|
|
151
160
|
#
|
|
152
161
|
# f = self.method(:f)
|
|
153
|
-
# g = proc {|
|
|
154
|
-
#
|
|
162
|
+
# g = proc { |ary| ary << 'in proc' }
|
|
163
|
+
# (f << g).call([]) # => ["in proc", "in f"]
|
|
155
164
|
#
|
|
156
165
|
def <<: (Proc::_Callable g) -> Proc
|
|
157
166
|
|
|
@@ -163,23 +172,32 @@ class Method
|
|
|
163
172
|
# m.call(3) #=> 15
|
|
164
173
|
# m.call(20) #=> 32
|
|
165
174
|
#
|
|
175
|
+
# Using Method#=== allows a method object to be the target of a `when` clause in
|
|
176
|
+
# a case statement.
|
|
177
|
+
#
|
|
178
|
+
# require 'prime'
|
|
179
|
+
#
|
|
180
|
+
# case 1373
|
|
181
|
+
# when Prime.method(:prime?)
|
|
182
|
+
# # ...
|
|
183
|
+
# end
|
|
184
|
+
#
|
|
166
185
|
alias === call
|
|
167
186
|
|
|
168
187
|
# <!--
|
|
169
188
|
# rdoc-file=proc.c
|
|
170
|
-
# -
|
|
189
|
+
# - self >> g -> a_proc
|
|
171
190
|
# -->
|
|
172
|
-
# Returns a proc that is the composition of this method and the given
|
|
173
|
-
# returned proc takes a variable number of arguments, calls this method with
|
|
174
|
-
# them then calls *g* with the result.
|
|
191
|
+
# Returns a proc that is the composition of this method and the given `g`.
|
|
175
192
|
#
|
|
176
|
-
#
|
|
177
|
-
#
|
|
178
|
-
#
|
|
193
|
+
# The returned proc takes a variable number of arguments. It first calls `self`
|
|
194
|
+
# with the arguments, then calls `g` with the return value of `self`.
|
|
195
|
+
#
|
|
196
|
+
# def f(ary) = ary << 'in f'
|
|
179
197
|
#
|
|
180
198
|
# f = self.method(:f)
|
|
181
|
-
# g = proc {|
|
|
182
|
-
#
|
|
199
|
+
# g = proc { |ary| ary << 'in proc' }
|
|
200
|
+
# (f >> g).call([]) # => ["in f", "in proc"]
|
|
183
201
|
#
|
|
184
202
|
def >>: (Proc::_Callable g) -> Proc
|
|
185
203
|
|
|
@@ -191,6 +209,16 @@ class Method
|
|
|
191
209
|
# m.call(3) #=> 15
|
|
192
210
|
# m.call(20) #=> 32
|
|
193
211
|
#
|
|
212
|
+
# Using Method#=== allows a method object to be the target of a `when` clause in
|
|
213
|
+
# a case statement.
|
|
214
|
+
#
|
|
215
|
+
# require 'prime'
|
|
216
|
+
#
|
|
217
|
+
# case 1373
|
|
218
|
+
# when Prime.method(:prime?)
|
|
219
|
+
# # ...
|
|
220
|
+
# end
|
|
221
|
+
#
|
|
194
222
|
alias [] call
|
|
195
223
|
|
|
196
224
|
# <!--
|
|
@@ -359,10 +387,18 @@ class Method
|
|
|
359
387
|
|
|
360
388
|
# <!--
|
|
361
389
|
# rdoc-file=proc.c
|
|
362
|
-
# - meth.source_location -> [String, Integer]
|
|
390
|
+
# - meth.source_location -> [String, Integer, Integer, Integer, Integer]
|
|
363
391
|
# -->
|
|
364
|
-
# Returns the
|
|
365
|
-
#
|
|
392
|
+
# Returns the location where the method was defined. The returned Array
|
|
393
|
+
# contains:
|
|
394
|
+
# (1) the Ruby source filename
|
|
395
|
+
# (2) the line number where the definition starts
|
|
396
|
+
# (3) the column number where the definition starts
|
|
397
|
+
# (4) the line number where the definition ends
|
|
398
|
+
# (5) the column number where the definitions ends
|
|
399
|
+
#
|
|
400
|
+
# This method will return `nil` if the method was not defined in Ruby (i.e.
|
|
401
|
+
# native).
|
|
366
402
|
#
|
|
367
403
|
def source_location: () -> [String, Integer]?
|
|
368
404
|
|
|
@@ -370,8 +406,8 @@ class Method
|
|
|
370
406
|
# rdoc-file=proc.c
|
|
371
407
|
# - meth.super_method -> method
|
|
372
408
|
# -->
|
|
373
|
-
# Returns a Method of superclass which would be called when super is used or
|
|
374
|
-
# if there is no method on superclass.
|
|
409
|
+
# Returns a `Method` of superclass which would be called when super is used or
|
|
410
|
+
# nil if there is no method on superclass.
|
|
375
411
|
#
|
|
376
412
|
def super_method: () -> Method?
|
|
377
413
|
|