rbs 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -0
- data/CHANGELOG.md +23 -0
- data/README.md +6 -1
- data/core/array.rbs +2866 -1086
- data/core/basic_object.rbs +150 -30
- data/core/binding.rbs +33 -0
- data/core/builtin.rbs +4 -4
- data/core/class.rbs +43 -5
- data/core/comparable.rbs +57 -0
- data/core/complex.rbs +170 -4
- data/core/constants.rbs +51 -0
- data/core/deprecated.rbs +7 -0
- data/core/dir.rbs +305 -20
- data/core/encoding.rbs +472 -77
- data/core/enumerable.rbs +2173 -234
- data/core/enumerator.rbs +448 -182
- data/core/env.rbs +448 -1
- data/core/errno.rbs +1 -10
- data/core/errors.rbs +152 -2
- data/core/exception.rbs +201 -127
- data/core/false_class.rbs +27 -0
- data/core/fiber.rbs +118 -37
- data/core/fiber_error.rbs +8 -9
- data/core/file.rbs +1059 -139
- data/core/file_test.rbs +287 -32
- data/core/float.rbs +776 -300
- data/core/gc.rbs +185 -34
- data/core/global_variables.rbs +5 -1
- data/core/hash.rbs +1582 -649
- data/core/integer.rbs +974 -204
- data/core/io/buffer.rbs +710 -0
- data/core/io/wait.rbs +29 -8
- data/core/io.rbs +2438 -417
- data/core/kernel.rbs +2315 -316
- data/core/marshal.rbs +37 -2
- data/core/match_data.rbs +123 -6
- data/core/math.rbs +126 -6
- data/core/method.rbs +226 -102
- data/core/module.rbs +421 -45
- data/core/nil_class.rbs +64 -0
- data/core/numeric.rbs +620 -142
- data/core/object.rbs +453 -81
- data/core/object_space.rbs +92 -2
- data/core/proc.rbs +482 -285
- data/core/process.rbs +443 -34
- data/core/ractor.rbs +232 -9
- data/core/random.rbs +151 -52
- data/core/range.rbs +885 -160
- data/core/rational.rbs +122 -6
- data/core/rb_config.rbs +14 -4
- data/core/refinement.rbs +44 -0
- data/core/regexp.rbs +156 -14
- data/core/ruby_vm.rbs +42 -3
- data/core/signal.rbs +78 -39
- data/core/string.rbs +2123 -567
- data/core/string_io.rbs +204 -0
- data/core/struct.rbs +283 -28
- data/core/symbol.rbs +304 -30
- data/core/thread.rbs +1288 -688
- data/core/thread_group.rbs +66 -10
- data/core/time.rbs +643 -217
- data/core/trace_point.rbs +100 -12
- data/core/true_class.rbs +24 -0
- data/core/unbound_method.rbs +73 -7
- data/core/warning.rbs +37 -12
- data/docs/CONTRIBUTING.md +40 -34
- data/docs/stdlib.md +3 -102
- data/lib/rbs/annotate/annotations.rb +197 -0
- data/lib/rbs/annotate/formatter.rb +80 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
- data/lib/rbs/annotate/rdoc_source.rb +120 -0
- data/lib/rbs/annotate.rb +6 -0
- data/lib/rbs/cli.rb +45 -1
- data/lib/rbs/definition_builder.rb +5 -1
- data/lib/rbs/location_aux.rb +12 -0
- data/lib/rbs/prototype/rb.rb +12 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/{collections.rbs → sources.rbs} +0 -0
- data/sig/location.rbs +6 -0
- data/sig/method_types.rbs +5 -1
- data/sig/polyfill.rbs +78 -0
- data/stdlib/abbrev/0/abbrev.rbs +6 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +31 -0
- data/stdlib/benchmark/0/benchmark.rbs +74 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
- data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
- data/stdlib/cgi/0/core.rbs +59 -0
- data/stdlib/coverage/0/coverage.rbs +164 -2
- data/stdlib/csv/0/csv.rbs +2862 -398
- data/stdlib/date/0/date.rbs +483 -25
- data/stdlib/date/0/date_time.rbs +187 -12
- data/stdlib/dbm/0/dbm.rbs +152 -17
- data/stdlib/digest/0/digest.rbs +146 -0
- data/stdlib/erb/0/erb.rbs +65 -245
- data/stdlib/fiber/0/fiber.rbs +73 -91
- data/stdlib/fileutils/0/fileutils.rbs +301 -1
- data/stdlib/find/0/find.rbs +9 -0
- data/stdlib/forwardable/0/forwardable.rbs +65 -1
- data/stdlib/io-console/0/io-console.rbs +227 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
- data/stdlib/json/0/json.rbs +1146 -144
- data/stdlib/logger/0/formatter.rbs +24 -0
- data/stdlib/logger/0/log_device.rbs +64 -0
- data/stdlib/logger/0/logger.rbs +165 -13
- data/stdlib/logger/0/period.rbs +10 -0
- data/stdlib/logger/0/severity.rbs +26 -0
- data/stdlib/monitor/0/monitor.rbs +163 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
- data/stdlib/net-http/0/net-http.rbs +1492 -683
- data/stdlib/nkf/0/nkf.rbs +372 -0
- data/stdlib/objspace/0/objspace.rbs +149 -90
- data/stdlib/openssl/0/openssl.rbs +8108 -71
- data/stdlib/optparse/0/optparse.rbs +487 -19
- data/stdlib/pathname/0/pathname.rbs +425 -124
- data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
- data/stdlib/prime/0/integer-extension.rbs +20 -2
- data/stdlib/prime/0/prime.rbs +88 -21
- data/stdlib/pstore/0/pstore.rbs +102 -0
- data/stdlib/pty/0/pty.rbs +64 -14
- data/stdlib/resolv/0/resolv.rbs +420 -31
- data/stdlib/rubygems/0/basic_specification.rbs +4 -1
- data/stdlib/rubygems/0/config_file.rbs +33 -1
- data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
- data/stdlib/rubygems/0/installer.rbs +13 -1
- data/stdlib/rubygems/0/path_support.rbs +4 -1
- data/stdlib/rubygems/0/platform.rbs +5 -1
- data/stdlib/rubygems/0/request_set.rbs +44 -2
- data/stdlib/rubygems/0/requirement.rbs +65 -2
- data/stdlib/rubygems/0/rubygems.rbs +407 -0
- data/stdlib/rubygems/0/source_list.rbs +13 -0
- data/stdlib/rubygems/0/specification.rbs +21 -1
- data/stdlib/rubygems/0/stream_ui.rbs +3 -1
- data/stdlib/rubygems/0/uninstaller.rbs +8 -1
- data/stdlib/rubygems/0/version.rbs +60 -157
- data/stdlib/securerandom/0/securerandom.rbs +44 -0
- data/stdlib/set/0/set.rbs +420 -106
- data/stdlib/shellwords/0/shellwords.rbs +55 -77
- data/stdlib/singleton/0/singleton.rbs +20 -0
- data/stdlib/socket/0/addrinfo.rbs +210 -9
- data/stdlib/socket/0/basic_socket.rbs +103 -11
- data/stdlib/socket/0/ip_socket.rbs +31 -9
- data/stdlib/socket/0/socket.rbs +586 -38
- data/stdlib/socket/0/tcp_server.rbs +22 -2
- data/stdlib/socket/0/tcp_socket.rbs +12 -1
- data/stdlib/socket/0/udp_socket.rbs +25 -2
- data/stdlib/socket/0/unix_server.rbs +22 -2
- data/stdlib/socket/0/unix_socket.rbs +45 -5
- data/stdlib/strscan/0/string_scanner.rbs +210 -9
- data/stdlib/tempfile/0/tempfile.rbs +58 -10
- data/stdlib/time/0/time.rbs +208 -116
- data/stdlib/timeout/0/timeout.rbs +10 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
- data/stdlib/tsort/0/cyclic.rbs +1 -0
- data/stdlib/tsort/0/interfaces.rbs +1 -0
- data/stdlib/tsort/0/tsort.rbs +42 -0
- data/stdlib/uri/0/common.rbs +57 -8
- data/stdlib/uri/0/file.rbs +55 -109
- data/stdlib/uri/0/ftp.rbs +6 -3
- data/stdlib/uri/0/generic.rbs +556 -327
- data/stdlib/uri/0/http.rbs +26 -115
- data/stdlib/uri/0/https.rbs +8 -102
- data/stdlib/uri/0/ldap.rbs +143 -137
- data/stdlib/uri/0/ldaps.rbs +8 -102
- data/stdlib/uri/0/mailto.rbs +3 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
- data/stdlib/uri/0/ws.rbs +6 -3
- data/stdlib/uri/0/wss.rbs +5 -3
- data/stdlib/yaml/0/dbm.rbs +151 -87
- data/stdlib/yaml/0/store.rbs +6 -0
- data/stdlib/zlib/0/zlib.rbs +90 -31
- metadata +17 -5
- data/lib/rbs/location.rb +0 -221
data/core/marshal.rbs
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# <!-- rdoc-file=marshal.c -->
|
1
2
|
# The marshaling library converts collections of Ruby objects into a byte
|
2
3
|
# stream, allowing them to be stored outside the currently active script. This
|
3
4
|
# data may subsequently be read and the original objects reconstituted.
|
@@ -107,6 +108,10 @@
|
|
107
108
|
# which is Marshal.loaded in _load for complex objects.
|
108
109
|
#
|
109
110
|
module Marshal
|
111
|
+
# <!--
|
112
|
+
# rdoc-file=marshal.c
|
113
|
+
# - dump( obj [, anIO] , limit=-1 ) -> anIO
|
114
|
+
# -->
|
110
115
|
# Serializes obj and all descendant objects. If anIO is specified, the
|
111
116
|
# serialized data will be written to it, otherwise the data will be returned as
|
112
117
|
# a String. If limit is specified, the traversal of subobjects will be limited
|
@@ -139,6 +144,11 @@ module Marshal
|
|
139
144
|
def self.dump: (untyped obj, untyped port, ?Integer limit) -> untyped
|
140
145
|
| (untyped obj, ?Integer limit) -> String
|
141
146
|
|
147
|
+
# <!--
|
148
|
+
# rdoc-file=marshal.rb
|
149
|
+
# - load(source, proc = nil, freeze: false) -> obj
|
150
|
+
# - restore(source, proc = nil, freeze: false) -> obj
|
151
|
+
# -->
|
142
152
|
# Returns the result of converting the serialized data in source into a Ruby
|
143
153
|
# object (possibly with associated subordinate objects). source may be either an
|
144
154
|
# instance of IO or an object that responds to to_str. If proc is specified,
|
@@ -147,16 +157,41 @@ module Marshal
|
|
147
157
|
# Never pass untrusted data (including user supplied input) to this method.
|
148
158
|
# Please see the overview for further details.
|
149
159
|
#
|
150
|
-
|
151
|
-
|
160
|
+
# If the `freeze: true` argument is passed, deserialized object would be deeply
|
161
|
+
# frozen. Note that it may lead to more efficient memory usage due to frozen
|
162
|
+
# strings deduplication:
|
163
|
+
#
|
164
|
+
# serialized = Marshal.dump(['value1', 'value2', 'value1', 'value2'])
|
165
|
+
#
|
166
|
+
# deserialized = Marshal.load(serialized)
|
167
|
+
# deserialized.map(&:frozen?)
|
168
|
+
# # => [false, false, false, false]
|
169
|
+
# deserialized.map(&:object_id)
|
170
|
+
# # => [1023900, 1023920, 1023940, 1023960] -- 4 different objects
|
171
|
+
#
|
172
|
+
# deserialized = Marshal.load(serialized, freeze: true)
|
173
|
+
# deserialized.map(&:frozen?)
|
174
|
+
# # => [true, true, true, true]
|
175
|
+
# deserialized.map(&:object_id)
|
176
|
+
# # => [1039360, 1039380, 1039360, 1039380] -- only 2 different objects, object_ids repeating
|
177
|
+
#
|
178
|
+
def self.load: (String | untyped port, ?freeze: boolish) -> untyped
|
179
|
+
| [A] (String | untyped port, ^(untyped) -> A, ?freeze: boolish) -> A
|
152
180
|
|
181
|
+
# <!--
|
182
|
+
# rdoc-file=marshal.rb
|
183
|
+
# - restore(source, proc = nil, freeze: false)
|
184
|
+
# -->
|
185
|
+
#
|
153
186
|
alias self.restore self.load
|
154
187
|
end
|
155
188
|
|
189
|
+
# <!-- rdoc-file=marshal.c -->
|
156
190
|
# major version
|
157
191
|
#
|
158
192
|
Marshal::MAJOR_VERSION: Integer
|
159
193
|
|
194
|
+
# <!-- rdoc-file=marshal.c -->
|
160
195
|
# minor version
|
161
196
|
#
|
162
197
|
Marshal::MINOR_VERSION: Integer
|
data/core/match_data.rbs
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# <!-- rdoc-file=re.c -->
|
1
2
|
# MatchData encapsulates the result of matching a Regexp against string. It is
|
2
3
|
# returned by Regexp#match and String#match, and also stored in a global
|
3
4
|
# variable returned by Regexp.last_match.
|
@@ -34,11 +35,11 @@
|
|
34
35
|
# global variables:
|
35
36
|
#
|
36
37
|
# * `$~` is Regexp.last_match;
|
37
|
-
# * `$&` is
|
38
|
-
# * `$1`, `$2`, and so on are
|
38
|
+
# * `$&` is Regexp.last_match`[ 0 ]`;
|
39
|
+
# * `$1`, `$2`, and so on are Regexp.last_match`[ i ]` (captures by number);
|
39
40
|
# * `$`` is Regexp.last_match`.pre_match`;
|
40
41
|
# * `$'` is Regexp.last_match`.post_match`;
|
41
|
-
# * `$+` is
|
42
|
+
# * `$+` is Regexp.last_match`[ -1 ]` (the last capture).
|
42
43
|
#
|
43
44
|
#
|
44
45
|
# See also "Special global variables" section in Regexp documentation.
|
@@ -46,11 +47,19 @@
|
|
46
47
|
class MatchData
|
47
48
|
public
|
48
49
|
|
50
|
+
# <!-- rdoc-file=re.c -->
|
49
51
|
# Equality---Two matchdata are equal if their target strings, patterns, and
|
50
52
|
# matched positions are identical.
|
51
53
|
#
|
52
54
|
def ==: (untyped other) -> bool
|
53
55
|
|
56
|
+
# <!--
|
57
|
+
# rdoc-file=re.c
|
58
|
+
# - mtch[i] -> str or nil
|
59
|
+
# - mtch[start, length] -> array
|
60
|
+
# - mtch[range] -> array
|
61
|
+
# - mtch[name] -> str or nil
|
62
|
+
# -->
|
54
63
|
# Match Reference -- MatchData acts as an array, and may be accessed using the
|
55
64
|
# normal array indexing techniques. `mtch[0]` is equivalent to the special
|
56
65
|
# variable `$&`, and returns the entire matched string. `mtch[1]`, `mtch[2]`,
|
@@ -74,6 +83,10 @@ class MatchData
|
|
74
83
|
| (::Range[Integer] range) -> ::Array[String?]
|
75
84
|
| (String | Symbol name) -> String?
|
76
85
|
|
86
|
+
# <!--
|
87
|
+
# rdoc-file=re.c
|
88
|
+
# - mtch.begin(n) -> integer
|
89
|
+
# -->
|
77
90
|
# Returns the offset of the start of the *n*th element of the match array in the
|
78
91
|
# string. *n* can be a string or symbol to reference a named capture.
|
79
92
|
#
|
@@ -87,6 +100,10 @@ class MatchData
|
|
87
100
|
#
|
88
101
|
def begin: (Integer | String | Symbol n_or_name) -> Integer?
|
89
102
|
|
103
|
+
# <!--
|
104
|
+
# rdoc-file=re.c
|
105
|
+
# - mtch.captures -> array
|
106
|
+
# -->
|
90
107
|
# Returns the array of captures; equivalent to `mtch.to_a[1..-1]`.
|
91
108
|
#
|
92
109
|
# f1,f2,f3,f4 = /(.)(.)(\d+)(\d)/.match("THX1138.").captures
|
@@ -97,6 +114,10 @@ class MatchData
|
|
97
114
|
#
|
98
115
|
def captures: () -> ::Array[String?]
|
99
116
|
|
117
|
+
# <!--
|
118
|
+
# rdoc-file=re.c
|
119
|
+
# - mtch.end(n) -> integer
|
120
|
+
# -->
|
100
121
|
# Returns the offset of the character immediately following the end of the *n*th
|
101
122
|
# element of the match array in the string. *n* can be a string or symbol to
|
102
123
|
# reference a named capture.
|
@@ -109,13 +130,22 @@ class MatchData
|
|
109
130
|
# p m.end(:foo) #=> 1
|
110
131
|
# p m.end(:bar) #=> 3
|
111
132
|
#
|
112
|
-
def
|
133
|
+
def end: (Integer | String | Symbol n_or_name) -> Integer?
|
113
134
|
|
135
|
+
# <!--
|
136
|
+
# rdoc-file=re.c
|
137
|
+
# - mtch == mtch2 -> true or false
|
138
|
+
# - mtch.eql?(mtch2) -> true or false
|
139
|
+
# -->
|
114
140
|
# Equality---Two matchdata are equal if their target strings, patterns, and
|
115
141
|
# matched positions are identical.
|
116
142
|
#
|
117
143
|
def eql?: (untyped other) -> bool
|
118
144
|
|
145
|
+
# <!--
|
146
|
+
# rdoc-file=re.c
|
147
|
+
# - mtch.hash -> integer
|
148
|
+
# -->
|
119
149
|
# Produce a hash based on the target string, regexp and matched positions of
|
120
150
|
# this matchdata.
|
121
151
|
#
|
@@ -123,6 +153,10 @@ class MatchData
|
|
123
153
|
#
|
124
154
|
def hash: () -> Integer
|
125
155
|
|
156
|
+
# <!--
|
157
|
+
# rdoc-file=re.c
|
158
|
+
# - mtch.inspect -> str
|
159
|
+
# -->
|
126
160
|
# Returns a printable version of *mtch*.
|
127
161
|
#
|
128
162
|
# puts /.$/.match("foo").inspect
|
@@ -139,6 +173,7 @@ class MatchData
|
|
139
173
|
#
|
140
174
|
def inspect: () -> String
|
141
175
|
|
176
|
+
# <!-- rdoc-file=re.c -->
|
142
177
|
# Returns the number of elements in the match array.
|
143
178
|
#
|
144
179
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
@@ -147,6 +182,10 @@ class MatchData
|
|
147
182
|
#
|
148
183
|
def length: () -> Integer
|
149
184
|
|
185
|
+
# <!--
|
186
|
+
# rdoc-file=re.c
|
187
|
+
# - mtch.named_captures -> hash
|
188
|
+
# -->
|
150
189
|
# Returns a Hash using named capture.
|
151
190
|
#
|
152
191
|
# A key of the hash is a name of the named captures. A value of the hash is a
|
@@ -166,8 +205,12 @@ class MatchData
|
|
166
205
|
#
|
167
206
|
def named_captures: () -> ::Hash[String, String?]
|
168
207
|
|
169
|
-
#
|
170
|
-
#
|
208
|
+
# <!--
|
209
|
+
# rdoc-file=re.c
|
210
|
+
# - mtch.names -> [name1, name2, ...]
|
211
|
+
# -->
|
212
|
+
# Returns a list of names of captures as an array of strings. This is the same
|
213
|
+
# as mtch.regexp.names.
|
171
214
|
#
|
172
215
|
# /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge").names
|
173
216
|
# #=> ["foo", "bar", "baz"]
|
@@ -177,6 +220,46 @@ class MatchData
|
|
177
220
|
#
|
178
221
|
def names: () -> ::Array[String]
|
179
222
|
|
223
|
+
# <!--
|
224
|
+
# rdoc-file=re.c
|
225
|
+
# - mtch.match(n) -> string or nil
|
226
|
+
# -->
|
227
|
+
# Returns the captured substring corresponding to the argument. *n* can be a
|
228
|
+
# string or symbol to reference a named capture.
|
229
|
+
#
|
230
|
+
# m = /(.)(.)(\d+)(\d)(\w)?/.match("THX1138.")
|
231
|
+
# m.match(0) #=> "HX1138"
|
232
|
+
# m.match(4) #=> "8"
|
233
|
+
# m.match(5) #=> nil
|
234
|
+
#
|
235
|
+
# m = /(?<foo>.)(.)(?<bar>.+)/.match("hoge")
|
236
|
+
# m.match(:foo) #=> "h"
|
237
|
+
# m.match(:bar) #=> "ge"
|
238
|
+
#
|
239
|
+
def match: (int | String | Symbol) -> String?
|
240
|
+
|
241
|
+
# <!--
|
242
|
+
# rdoc-file=re.c
|
243
|
+
# - mtch.match_length(n) -> array
|
244
|
+
# -->
|
245
|
+
# Returns the length of the captured substring corresponding to the argument.
|
246
|
+
# *n* can be a string or symbol to reference a named capture.
|
247
|
+
#
|
248
|
+
# m = /(.)(.)(\d+)(\d)(\w)?/.match("THX1138.")
|
249
|
+
# m.match_length(0) #=> 6
|
250
|
+
# m.match_length(4) #=> 1
|
251
|
+
# m.match_length(5) #=> nil
|
252
|
+
#
|
253
|
+
# m = /(?<foo>.)(.)(?<bar>.+)/.match("hoge")
|
254
|
+
# m.match_length(:foo) #=> 1
|
255
|
+
# m.match_length(:bar) #=> 2
|
256
|
+
#
|
257
|
+
def match_length: (int | String | Symbol) -> Integer?
|
258
|
+
|
259
|
+
# <!--
|
260
|
+
# rdoc-file=re.c
|
261
|
+
# - mtch.offset(n) -> array
|
262
|
+
# -->
|
180
263
|
# Returns a two-element array containing the beginning and ending offsets of the
|
181
264
|
# *n*th match. *n* can be a string or symbol to reference a named capture.
|
182
265
|
#
|
@@ -190,6 +273,10 @@ class MatchData
|
|
190
273
|
#
|
191
274
|
def offset: (Integer | Symbol | String n_or_name) -> ([ Integer, Integer ] | [ nil, nil ])
|
192
275
|
|
276
|
+
# <!--
|
277
|
+
# rdoc-file=re.c
|
278
|
+
# - mtch.post_match -> str
|
279
|
+
# -->
|
193
280
|
# Returns the portion of the original string after the current match. Equivalent
|
194
281
|
# to the special variable `$'`.
|
195
282
|
#
|
@@ -198,6 +285,10 @@ class MatchData
|
|
198
285
|
#
|
199
286
|
def post_match: () -> String
|
200
287
|
|
288
|
+
# <!--
|
289
|
+
# rdoc-file=re.c
|
290
|
+
# - mtch.pre_match -> str
|
291
|
+
# -->
|
201
292
|
# Returns the portion of the original string before the current match.
|
202
293
|
# Equivalent to the special variable `$``.
|
203
294
|
#
|
@@ -206,6 +297,10 @@ class MatchData
|
|
206
297
|
#
|
207
298
|
def pre_match: () -> String
|
208
299
|
|
300
|
+
# <!--
|
301
|
+
# rdoc-file=re.c
|
302
|
+
# - mtch.regexp -> regexp
|
303
|
+
# -->
|
209
304
|
# Returns the regexp.
|
210
305
|
#
|
211
306
|
# m = /a.*b/.match("abc")
|
@@ -213,6 +308,11 @@ class MatchData
|
|
213
308
|
#
|
214
309
|
def regexp: () -> Regexp
|
215
310
|
|
311
|
+
# <!--
|
312
|
+
# rdoc-file=re.c
|
313
|
+
# - mtch.length -> integer
|
314
|
+
# - mtch.size -> integer
|
315
|
+
# -->
|
216
316
|
# Returns the number of elements in the match array.
|
217
317
|
#
|
218
318
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
@@ -221,6 +321,10 @@ class MatchData
|
|
221
321
|
#
|
222
322
|
def size: () -> Integer
|
223
323
|
|
324
|
+
# <!--
|
325
|
+
# rdoc-file=re.c
|
326
|
+
# - mtch.string -> str
|
327
|
+
# -->
|
224
328
|
# Returns a frozen copy of the string passed in to `match`.
|
225
329
|
#
|
226
330
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
@@ -228,6 +332,10 @@ class MatchData
|
|
228
332
|
#
|
229
333
|
def string: () -> String
|
230
334
|
|
335
|
+
# <!--
|
336
|
+
# rdoc-file=re.c
|
337
|
+
# - mtch.to_a -> anArray
|
338
|
+
# -->
|
231
339
|
# Returns the array of matches.
|
232
340
|
#
|
233
341
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
@@ -245,6 +353,10 @@ class MatchData
|
|
245
353
|
#
|
246
354
|
def to_a: () -> ::Array[String?]
|
247
355
|
|
356
|
+
# <!--
|
357
|
+
# rdoc-file=re.c
|
358
|
+
# - mtch.to_s -> str
|
359
|
+
# -->
|
248
360
|
# Returns the entire matched string.
|
249
361
|
#
|
250
362
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138.")
|
@@ -252,12 +364,17 @@ class MatchData
|
|
252
364
|
#
|
253
365
|
def to_s: () -> String
|
254
366
|
|
367
|
+
# <!--
|
368
|
+
# rdoc-file=re.c
|
369
|
+
# - mtch.values_at(index, ...) -> array
|
370
|
+
# -->
|
255
371
|
# Uses each *index* to access the matching values, returning an array of the
|
256
372
|
# corresponding matches.
|
257
373
|
#
|
258
374
|
# m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
259
375
|
# m.to_a #=> ["HX1138", "H", "X", "113", "8"]
|
260
376
|
# m.values_at(0, 2, -2) #=> ["HX1138", "X", "113"]
|
377
|
+
# m.values_at(1..2, -1) #=> ["H", "X", "8"]
|
261
378
|
#
|
262
379
|
# m = /(?<a>\d+) *(?<op>[+\-*\/]) *(?<b>\d+)/.match("1 + 2")
|
263
380
|
# m.to_a #=> ["1 + 2", "1", "+", "2"]
|
data/core/math.rbs
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# <!-- rdoc-file=math.c -->
|
1
2
|
# The Math module contains module functions for basic trigonometric and
|
2
3
|
# transcendental functions. See class Float for a list of constants that define
|
3
4
|
# Ruby's floating point accuracy.
|
@@ -5,6 +6,10 @@
|
|
5
6
|
# Domains and codomains are given only for real (not complex) numbers.
|
6
7
|
#
|
7
8
|
module Math
|
9
|
+
# <!--
|
10
|
+
# rdoc-file=math.c
|
11
|
+
# - Math.acos(x) -> Float
|
12
|
+
# -->
|
8
13
|
# Computes the arc cosine of `x`. Returns 0..PI.
|
9
14
|
#
|
10
15
|
# Domain: [-1, 1]
|
@@ -15,6 +20,10 @@ module Math
|
|
15
20
|
#
|
16
21
|
def self.acos: (Numeric x) -> Float
|
17
22
|
|
23
|
+
# <!--
|
24
|
+
# rdoc-file=math.c
|
25
|
+
# - Math.acosh(x) -> Float
|
26
|
+
# -->
|
18
27
|
# Computes the inverse hyperbolic cosine of `x`.
|
19
28
|
#
|
20
29
|
# Domain: [1, INFINITY)
|
@@ -25,6 +34,10 @@ module Math
|
|
25
34
|
#
|
26
35
|
def self.acosh: (Numeric x) -> Float
|
27
36
|
|
37
|
+
# <!--
|
38
|
+
# rdoc-file=math.c
|
39
|
+
# - Math.asin(x) -> Float
|
40
|
+
# -->
|
28
41
|
# Computes the arc sine of `x`. Returns -PI/2..PI/2.
|
29
42
|
#
|
30
43
|
# Domain: [-1, -1]
|
@@ -35,6 +48,10 @@ module Math
|
|
35
48
|
#
|
36
49
|
def self.asin: (Numeric x) -> Float
|
37
50
|
|
51
|
+
# <!--
|
52
|
+
# rdoc-file=math.c
|
53
|
+
# - Math.asinh(x) -> Float
|
54
|
+
# -->
|
38
55
|
# Computes the inverse hyperbolic sine of `x`.
|
39
56
|
#
|
40
57
|
# Domain: (-INFINITY, INFINITY)
|
@@ -45,6 +62,10 @@ module Math
|
|
45
62
|
#
|
46
63
|
def self.asinh: (Numeric x) -> Float
|
47
64
|
|
65
|
+
# <!--
|
66
|
+
# rdoc-file=math.c
|
67
|
+
# - Math.atan(x) -> Float
|
68
|
+
# -->
|
48
69
|
# Computes the arc tangent of `x`. Returns -PI/2..PI/2.
|
49
70
|
#
|
50
71
|
# Domain: (-INFINITY, INFINITY)
|
@@ -55,6 +76,10 @@ module Math
|
|
55
76
|
#
|
56
77
|
def self.atan: (Numeric x) -> Float
|
57
78
|
|
79
|
+
# <!--
|
80
|
+
# rdoc-file=math.c
|
81
|
+
# - Math.atan2(y, x) -> Float
|
82
|
+
# -->
|
58
83
|
# Computes the arc tangent given `y` and `x`. Returns a Float in the range
|
59
84
|
# -PI..PI. Return value is a angle in radians between the positive x-axis of
|
60
85
|
# cartesian plane and the point given by the coordinates (`x`, `y`) on it.
|
@@ -80,6 +105,10 @@ module Math
|
|
80
105
|
#
|
81
106
|
def self.atan2: (Numeric y, Numeric x) -> Float
|
82
107
|
|
108
|
+
# <!--
|
109
|
+
# rdoc-file=math.c
|
110
|
+
# - Math.atanh(x) -> Float
|
111
|
+
# -->
|
83
112
|
# Computes the inverse hyperbolic tangent of `x`.
|
84
113
|
#
|
85
114
|
# Domain: (-1, 1)
|
@@ -90,6 +119,10 @@ module Math
|
|
90
119
|
#
|
91
120
|
def self.atanh: (Numeric x) -> Float
|
92
121
|
|
122
|
+
# <!--
|
123
|
+
# rdoc-file=math.c
|
124
|
+
# - Math.cbrt(x) -> Float
|
125
|
+
# -->
|
93
126
|
# Returns the cube root of `x`.
|
94
127
|
#
|
95
128
|
# Domain: (-INFINITY, INFINITY)
|
@@ -121,6 +154,10 @@ module Math
|
|
121
154
|
#
|
122
155
|
def self.cbrt: (Numeric x) -> Float
|
123
156
|
|
157
|
+
# <!--
|
158
|
+
# rdoc-file=math.c
|
159
|
+
# - Math.cos(x) -> Float
|
160
|
+
# -->
|
124
161
|
# Computes the cosine of `x` (expressed in radians). Returns a Float in the
|
125
162
|
# range -1.0..1.0.
|
126
163
|
#
|
@@ -132,6 +169,10 @@ module Math
|
|
132
169
|
#
|
133
170
|
def self.cos: (Numeric x) -> Float
|
134
171
|
|
172
|
+
# <!--
|
173
|
+
# rdoc-file=math.c
|
174
|
+
# - Math.cosh(x) -> Float
|
175
|
+
# -->
|
135
176
|
# Computes the hyperbolic cosine of `x` (expressed in radians).
|
136
177
|
#
|
137
178
|
# Domain: (-INFINITY, INFINITY)
|
@@ -142,6 +183,10 @@ module Math
|
|
142
183
|
#
|
143
184
|
def self.cosh: (Numeric x) -> Float
|
144
185
|
|
186
|
+
# <!--
|
187
|
+
# rdoc-file=math.c
|
188
|
+
# - Math.erf(x) -> Float
|
189
|
+
# -->
|
145
190
|
# Calculates the error function of `x`.
|
146
191
|
#
|
147
192
|
# Domain: (-INFINITY, INFINITY)
|
@@ -152,6 +197,10 @@ module Math
|
|
152
197
|
#
|
153
198
|
def self.erf: (Numeric x) -> Float
|
154
199
|
|
200
|
+
# <!--
|
201
|
+
# rdoc-file=math.c
|
202
|
+
# - Math.erfc(x) -> Float
|
203
|
+
# -->
|
155
204
|
# Calculates the complementary error function of x.
|
156
205
|
#
|
157
206
|
# Domain: (-INFINITY, INFINITY)
|
@@ -162,6 +211,10 @@ module Math
|
|
162
211
|
#
|
163
212
|
def self.erfc: (Numeric x) -> Float
|
164
213
|
|
214
|
+
# <!--
|
215
|
+
# rdoc-file=math.c
|
216
|
+
# - Math.exp(x) -> Float
|
217
|
+
# -->
|
165
218
|
# Returns e**x.
|
166
219
|
#
|
167
220
|
# Domain: (-INFINITY, INFINITY)
|
@@ -174,6 +227,10 @@ module Math
|
|
174
227
|
#
|
175
228
|
def self.exp: (Numeric x) -> Float
|
176
229
|
|
230
|
+
# <!--
|
231
|
+
# rdoc-file=math.c
|
232
|
+
# - Math.frexp(x) -> [fraction, exponent]
|
233
|
+
# -->
|
177
234
|
# Returns a two-element array containing the normalized fraction (a Float) and
|
178
235
|
# exponent (an Integer) of `x`.
|
179
236
|
#
|
@@ -182,10 +239,14 @@ module Math
|
|
182
239
|
#
|
183
240
|
def self.frexp: (Numeric x) -> [ Float, Integer ]
|
184
241
|
|
242
|
+
# <!--
|
243
|
+
# rdoc-file=math.c
|
244
|
+
# - Math.gamma(x) -> Float
|
245
|
+
# -->
|
185
246
|
# Calculates the gamma function of x.
|
186
247
|
#
|
187
|
-
# Note that gamma(n) is same as fact(n-1) for integer n > 0. However
|
188
|
-
# returns float and can be an approximation.
|
248
|
+
# Note that gamma(n) is the same as fact(n-1) for integer n > 0. However
|
249
|
+
# gamma(n) returns float and can be an approximation.
|
189
250
|
#
|
190
251
|
# def fact(n) (1..n).inject(1) {|r,i| r*i } end
|
191
252
|
# 1.upto(26) {|i| p [i, Math.gamma(i), fact(i-1)] }
|
@@ -218,6 +279,10 @@ module Math
|
|
218
279
|
#
|
219
280
|
def self.gamma: (Numeric x) -> Float
|
220
281
|
|
282
|
+
# <!--
|
283
|
+
# rdoc-file=math.c
|
284
|
+
# - Math.hypot(x, y) -> Float
|
285
|
+
# -->
|
221
286
|
# Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle with
|
222
287
|
# sides `x` and `y`.
|
223
288
|
#
|
@@ -225,6 +290,10 @@ module Math
|
|
225
290
|
#
|
226
291
|
def self.hypot: (Numeric x, Numeric y) -> Float
|
227
292
|
|
293
|
+
# <!--
|
294
|
+
# rdoc-file=math.c
|
295
|
+
# - Math.ldexp(fraction, exponent) -> float
|
296
|
+
# -->
|
228
297
|
# Returns the value of `fraction`*(2**`exponent`).
|
229
298
|
#
|
230
299
|
# fraction, exponent = Math.frexp(1234)
|
@@ -232,19 +301,45 @@ module Math
|
|
232
301
|
#
|
233
302
|
def self.ldexp: (Numeric fraction, Numeric exponent) -> Float
|
234
303
|
|
304
|
+
# <!--
|
305
|
+
# rdoc-file=math.c
|
306
|
+
# - Math.lgamma(x) -> [float, -1 or 1]
|
307
|
+
# -->
|
235
308
|
# Calculates the logarithmic gamma of `x` and the sign of gamma of `x`.
|
236
309
|
#
|
237
|
-
# Math.lgamma(x) is same as
|
310
|
+
# Math.lgamma(x) is the same as
|
238
311
|
# [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
|
239
312
|
#
|
240
|
-
# but
|
313
|
+
# but avoids overflow by Math.gamma(x) for large x.
|
241
314
|
#
|
242
315
|
# Math.lgamma(0) #=> [Infinity, 1]
|
243
316
|
#
|
244
317
|
def self.lgamma: (Numeric x) -> [ Float, Integer ]
|
245
318
|
|
319
|
+
# <!--
|
320
|
+
# rdoc-file=math.c
|
321
|
+
# - Math.log(x) -> Float
|
322
|
+
# - Math.log(x, base) -> Float
|
323
|
+
# -->
|
324
|
+
# Returns the logarithm of `x`. If additional second argument is given, it will
|
325
|
+
# be the base of logarithm. Otherwise it is `e` (for the natural logarithm).
|
326
|
+
#
|
327
|
+
# Domain: (0, INFINITY)
|
328
|
+
#
|
329
|
+
# Codomain: (-INFINITY, INFINITY)
|
330
|
+
#
|
331
|
+
# Math.log(0) #=> -Infinity
|
332
|
+
# Math.log(1) #=> 0.0
|
333
|
+
# Math.log(Math::E) #=> 1.0
|
334
|
+
# Math.log(Math::E**3) #=> 3.0
|
335
|
+
# Math.log(12, 3) #=> 2.2618595071429146
|
336
|
+
#
|
246
337
|
def self.log: (Numeric x, ?Numeric base) -> Float
|
247
338
|
|
339
|
+
# <!--
|
340
|
+
# rdoc-file=math.c
|
341
|
+
# - Math.log10(x) -> Float
|
342
|
+
# -->
|
248
343
|
# Returns the base 10 logarithm of `x`.
|
249
344
|
#
|
250
345
|
# Domain: (0, INFINITY)
|
@@ -257,6 +352,10 @@ module Math
|
|
257
352
|
#
|
258
353
|
def self.log10: (Numeric x) -> Float
|
259
354
|
|
355
|
+
# <!--
|
356
|
+
# rdoc-file=math.c
|
357
|
+
# - Math.log2(x) -> Float
|
358
|
+
# -->
|
260
359
|
# Returns the base 2 logarithm of `x`.
|
261
360
|
#
|
262
361
|
# Domain: (0, INFINITY)
|
@@ -270,6 +369,10 @@ module Math
|
|
270
369
|
#
|
271
370
|
def self.log2: (Numeric x) -> Float
|
272
371
|
|
372
|
+
# <!--
|
373
|
+
# rdoc-file=math.c
|
374
|
+
# - Math.sin(x) -> Float
|
375
|
+
# -->
|
273
376
|
# Computes the sine of `x` (expressed in radians). Returns a Float in the range
|
274
377
|
# -1.0..1.0.
|
275
378
|
#
|
@@ -281,6 +384,10 @@ module Math
|
|
281
384
|
#
|
282
385
|
def self.sin: (Numeric x) -> Float
|
283
386
|
|
387
|
+
# <!--
|
388
|
+
# rdoc-file=math.c
|
389
|
+
# - Math.sinh(x) -> Float
|
390
|
+
# -->
|
284
391
|
# Computes the hyperbolic sine of `x` (expressed in radians).
|
285
392
|
#
|
286
393
|
# Domain: (-INFINITY, INFINITY)
|
@@ -291,6 +398,10 @@ module Math
|
|
291
398
|
#
|
292
399
|
def self.sinh: (Numeric x) -> Float
|
293
400
|
|
401
|
+
# <!--
|
402
|
+
# rdoc-file=math.c
|
403
|
+
# - Math.sqrt(x) -> Float
|
404
|
+
# -->
|
294
405
|
# Returns the non-negative square root of `x`.
|
295
406
|
#
|
296
407
|
# Domain: [0, INFINITY)
|
@@ -321,6 +432,10 @@ module Math
|
|
321
432
|
#
|
322
433
|
def self.sqrt: (Numeric x) -> Float
|
323
434
|
|
435
|
+
# <!--
|
436
|
+
# rdoc-file=math.c
|
437
|
+
# - Math.tan(x) -> Float
|
438
|
+
# -->
|
324
439
|
# Computes the tangent of `x` (expressed in radians).
|
325
440
|
#
|
326
441
|
# Domain: (-INFINITY, INFINITY)
|
@@ -331,6 +446,10 @@ module Math
|
|
331
446
|
#
|
332
447
|
def self.tan: (Numeric x) -> Float
|
333
448
|
|
449
|
+
# <!--
|
450
|
+
# rdoc-file=math.c
|
451
|
+
# - Math.tanh(x) -> Float
|
452
|
+
# -->
|
334
453
|
# Computes the hyperbolic tangent of `x` (expressed in radians).
|
335
454
|
#
|
336
455
|
# Domain: (-INFINITY, INFINITY)
|
@@ -342,17 +461,18 @@ module Math
|
|
342
461
|
def self.tanh: (Numeric x) -> Float
|
343
462
|
end
|
344
463
|
|
464
|
+
# <!-- rdoc-file=math.c -->
|
345
465
|
# Definition of the mathematical constant E for Euler's number (e) as a Float
|
346
466
|
# number.
|
347
467
|
#
|
348
|
-
#
|
349
468
|
Math::E: Float
|
350
469
|
|
470
|
+
# <!-- rdoc-file=math.c -->
|
351
471
|
# Definition of the mathematical constant PI as a Float number.
|
352
472
|
#
|
353
|
-
#
|
354
473
|
Math::PI: Float
|
355
474
|
|
475
|
+
# <!-- rdoc-file=math.c -->
|
356
476
|
# Raised when a mathematical function is evaluated outside of its domain of
|
357
477
|
# definition.
|
358
478
|
#
|