rbs 3.0.0.dev.2 → 3.0.0.dev.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +2 -1
- data/.github/workflows/ruby.yml +4 -0
- data/Gemfile.lock +11 -11
- data/Rakefile +2 -2
- data/Steepfile +1 -1
- data/core/array.rbs +573 -423
- data/core/basic_object.rbs +11 -39
- data/core/binding.rbs +1 -1
- data/core/builtin.rbs +8 -0
- data/core/class.rbs +37 -0
- data/core/comparable.rbs +7 -18
- data/core/complex.rbs +2 -2
- data/core/data.rbs +419 -0
- data/core/dir.rbs +52 -104
- data/core/encoding.rbs +22 -181
- data/core/enumerable.rbs +212 -175
- data/core/enumerator/product.rbs +96 -0
- data/core/enumerator.rbs +57 -8
- data/core/errors.rbs +8 -2
- data/core/exception.rbs +41 -0
- data/core/fiber.rbs +95 -12
- data/core/file.rbs +840 -275
- data/core/file_test.rbs +34 -19
- data/core/float.rbs +40 -96
- data/core/gc.rbs +15 -3
- data/core/hash.rbs +113 -175
- data/core/integer.rbs +85 -145
- data/core/io/buffer.rbs +187 -60
- data/core/io/wait.rbs +28 -16
- data/core/io.rbs +1859 -1389
- data/core/kernel.rbs +525 -961
- data/core/match_data.rbs +306 -142
- data/core/math.rbs +506 -234
- data/core/method.rbs +0 -24
- data/core/module.rbs +110 -17
- data/core/nil_class.rbs +2 -0
- data/core/numeric.rbs +76 -144
- data/core/object.rbs +88 -212
- data/core/proc.rbs +17 -5
- data/core/process.rbs +22 -5
- data/core/ractor.rbs +1 -1
- data/core/random.rbs +20 -3
- data/core/range.rbs +91 -89
- data/core/rational.rbs +2 -3
- data/core/rbs/unnamed/argf.rbs +177 -120
- data/core/rbs/unnamed/env_class.rbs +89 -163
- data/core/rbs/unnamed/random.rbs +36 -12
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +462 -272
- data/core/ruby_vm.rbs +210 -0
- data/{stdlib/set/0 → core}/set.rbs +43 -47
- data/core/string.rbs +1403 -1332
- data/core/string_io.rbs +191 -107
- data/core/struct.rbs +67 -63
- data/core/symbol.rbs +187 -201
- data/core/thread.rbs +40 -35
- data/core/time.rbs +902 -826
- data/core/trace_point.rbs +55 -6
- data/core/unbound_method.rbs +48 -24
- data/docs/collection.md +4 -0
- data/docs/syntax.md +55 -0
- data/ext/rbs_extension/parser.c +5 -6
- data/lib/rbs/cli.rb +6 -1
- data/lib/rbs/collection/cleaner.rb +8 -1
- data/lib/rbs/collection/config/lockfile.rb +3 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
- data/lib/rbs/collection/config.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +9 -2
- data/lib/rbs/collection/sources/local.rb +79 -0
- data/lib/rbs/collection/sources.rb +8 -1
- data/lib/rbs/environment.rb +6 -5
- data/lib/rbs/environment_loader.rb +3 -2
- data/lib/rbs/errors.rb +18 -0
- data/lib/rbs/locator.rb +26 -7
- data/lib/rbs/sorter.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/sig/collection/sources.rbs +32 -3
- data/sig/environment.rbs +2 -3
- data/sig/locator.rbs +14 -2
- data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
- data/stdlib/cgi/0/core.rbs +16 -0
- data/stdlib/coverage/0/coverage.rbs +50 -8
- data/stdlib/csv/0/csv.rbs +1 -1
- data/stdlib/date/0/date.rbs +856 -726
- data/stdlib/date/0/date_time.rbs +83 -210
- data/stdlib/erb/0/erb.rbs +13 -36
- data/stdlib/etc/0/etc.rbs +127 -20
- data/stdlib/fileutils/0/fileutils.rbs +1290 -381
- data/stdlib/logger/0/logger.rbs +466 -316
- data/stdlib/net-http/0/net-http.rbs +2211 -534
- data/stdlib/nkf/0/nkf.rbs +5 -5
- data/stdlib/objspace/0/objspace.rbs +31 -14
- data/stdlib/openssl/0/openssl.rbs +11 -7
- data/stdlib/optparse/0/optparse.rbs +20 -17
- data/stdlib/pathname/0/pathname.rbs +21 -4
- data/stdlib/pstore/0/pstore.rbs +378 -154
- data/stdlib/pty/0/pty.rbs +24 -8
- data/stdlib/ripper/0/ripper.rbs +1650 -0
- data/stdlib/socket/0/addrinfo.rbs +9 -15
- data/stdlib/socket/0/socket.rbs +36 -3
- data/stdlib/strscan/0/string_scanner.rbs +7 -5
- data/stdlib/tempfile/0/tempfile.rbs +104 -44
- data/stdlib/time/0/time.rbs +2 -2
- data/stdlib/uri/0/file.rbs +5 -0
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/yaml/0/yaml.rbs +2 -2
- data/stdlib/zlib/0/zlib.rbs +1 -1
- metadata +8 -6
- data/core/deprecated.rbs +0 -9
- data/sig/shims/ripper.rbs +0 -8
data/core/method.rbs
CHANGED
@@ -254,30 +254,6 @@ class Method < Object
|
|
254
254
|
#
|
255
255
|
def parameters: () -> ::Array[[ :req | :opt | :rest | :keyreq | :key | :keyrest | :block, Symbol ] | [ :rest | :keyrest ]]
|
256
256
|
|
257
|
-
# <!--
|
258
|
-
# rdoc-file=proc.c
|
259
|
-
# - meth.private? -> true or false
|
260
|
-
# -->
|
261
|
-
# Returns whether the method is private.
|
262
|
-
#
|
263
|
-
def private?: () -> bool
|
264
|
-
|
265
|
-
# <!--
|
266
|
-
# rdoc-file=proc.c
|
267
|
-
# - meth.protected? -> true or false
|
268
|
-
# -->
|
269
|
-
# Returns whether the method is protected.
|
270
|
-
#
|
271
|
-
def protected?: () -> bool
|
272
|
-
|
273
|
-
# <!--
|
274
|
-
# rdoc-file=proc.c
|
275
|
-
# - meth.public? -> true or false
|
276
|
-
# -->
|
277
|
-
# Returns whether the method is public.
|
278
|
-
#
|
279
|
-
def public?: () -> bool
|
280
|
-
|
281
257
|
# <!--
|
282
258
|
# rdoc-file=proc.c
|
283
259
|
# - meth.receiver -> object
|
data/core/module.rbs
CHANGED
@@ -85,13 +85,41 @@ class Module < Object
|
|
85
85
|
#
|
86
86
|
def self.used_modules: () -> ::Array[Module]
|
87
87
|
|
88
|
+
# <!--
|
89
|
+
# rdoc-file=eval.c
|
90
|
+
# - used_refinements -> array
|
91
|
+
# -->
|
92
|
+
# Returns an array of all modules used in the current scope. The ordering of
|
93
|
+
# modules in the resulting array is not defined.
|
94
|
+
#
|
95
|
+
# module A
|
96
|
+
# refine Object do
|
97
|
+
# end
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# module B
|
101
|
+
# refine Object do
|
102
|
+
# end
|
103
|
+
# end
|
104
|
+
#
|
105
|
+
# using A
|
106
|
+
# using B
|
107
|
+
# p Module.used_refinements
|
108
|
+
#
|
109
|
+
# *produces:*
|
110
|
+
#
|
111
|
+
# [#<refinement:Object@B>, #<refinement:Object@A>]
|
112
|
+
#
|
113
|
+
def self.used_refinements: () -> Array[Refinement]
|
114
|
+
|
88
115
|
# <!--
|
89
116
|
# rdoc-file=object.c
|
90
117
|
# - mod < other -> true, false, or nil
|
91
118
|
# -->
|
92
|
-
# Returns true if *mod* is a subclass of *other*. Returns `
|
93
|
-
#
|
94
|
-
#
|
119
|
+
# Returns true if *mod* is a subclass of *other*. Returns `false` if *mod* is
|
120
|
+
# the same as *other* or *mod* is an ancestor of *other*. Returns `nil` if
|
121
|
+
# there's no relationship between the two. (Think of the relationship in terms
|
122
|
+
# of the class definition: "class A < B" implies "A < B".)
|
95
123
|
#
|
96
124
|
def <: (Module other) -> bool?
|
97
125
|
|
@@ -169,9 +197,10 @@ class Module < Object
|
|
169
197
|
# rdoc-file=object.c
|
170
198
|
# - mod > other -> true, false, or nil
|
171
199
|
# -->
|
172
|
-
# Returns true if *mod* is an ancestor of *other*. Returns `
|
173
|
-
#
|
174
|
-
#
|
200
|
+
# Returns true if *mod* is an ancestor of *other*. Returns `false` if *mod* is
|
201
|
+
# the same as *other* or *mod* is a descendant of *other*. Returns `nil` if
|
202
|
+
# there's no relationship between the two. (Think of the relationship in terms
|
203
|
+
# of the class definition: "class A < B" implies "B > A".)
|
175
204
|
#
|
176
205
|
def >: (Module other) -> bool?
|
177
206
|
|
@@ -255,7 +284,7 @@ class Module < Object
|
|
255
284
|
# end
|
256
285
|
# Mod.instance_methods.sort #=> [:one, :one=, :two, :two=]
|
257
286
|
#
|
258
|
-
def attr_accessor: (*Symbol | String arg0) ->
|
287
|
+
def attr_accessor: (*Symbol | String arg0) -> Array[Symbol]
|
259
288
|
|
260
289
|
# <!--
|
261
290
|
# rdoc-file=object.c
|
@@ -269,7 +298,7 @@ class Module < Object
|
|
269
298
|
# in turn. String arguments are converted to symbols. Returns an array of
|
270
299
|
# defined method names as symbols.
|
271
300
|
#
|
272
|
-
def attr_reader: (*Symbol | String arg0) ->
|
301
|
+
def attr_reader: (*Symbol | String arg0) -> Array[Symbol]
|
273
302
|
|
274
303
|
# <!--
|
275
304
|
# rdoc-file=object.c
|
@@ -280,20 +309,24 @@ class Module < Object
|
|
280
309
|
# *symbol*`.id2name`. String arguments are converted to symbols. Returns an
|
281
310
|
# array of defined method names as symbols.
|
282
311
|
#
|
283
|
-
def attr_writer: (*Symbol | String arg0) ->
|
312
|
+
def attr_writer: (*Symbol | String arg0) -> Array[Symbol]
|
284
313
|
|
285
314
|
# <!--
|
286
315
|
# rdoc-file=load.c
|
287
|
-
# - mod.autoload(
|
316
|
+
# - mod.autoload(const, filename) -> nil
|
288
317
|
# -->
|
289
|
-
# Registers
|
290
|
-
#
|
291
|
-
#
|
318
|
+
# Registers _filename_ to be loaded (using Kernel::require)
|
319
|
+
# the first time that _const_ (which may be a String or
|
320
|
+
# a symbol) is accessed in the namespace of _mod_.
|
292
321
|
#
|
293
|
-
#
|
294
|
-
#
|
295
|
-
#
|
296
|
-
#
|
322
|
+
# module A
|
323
|
+
# end
|
324
|
+
# A.autoload(:B, "b")
|
325
|
+
# A::B.doit # autoloads "b"
|
326
|
+
#
|
327
|
+
# If *const* in *mod* is defined as autoload, the file name to be loaded is
|
328
|
+
# replaced with *filename*. If *const* is defined but not as autoload, does
|
329
|
+
# nothing.
|
297
330
|
#
|
298
331
|
def autoload: (Symbol _module, String filename) -> NilClass
|
299
332
|
|
@@ -436,6 +469,26 @@ class Module < Object
|
|
436
469
|
#
|
437
470
|
def class_variables: (?boolish inherit) -> ::Array[Symbol]
|
438
471
|
|
472
|
+
# <!--
|
473
|
+
# rdoc-file=object.c
|
474
|
+
# - const_added(const_name)
|
475
|
+
# -->
|
476
|
+
# Invoked as a callback whenever a constant is assigned on the receiver
|
477
|
+
#
|
478
|
+
# module Chatty
|
479
|
+
# def self.const_added(const_name)
|
480
|
+
# super
|
481
|
+
# puts "Added #{const_name.inspect}"
|
482
|
+
# end
|
483
|
+
# FOO = 1
|
484
|
+
# end
|
485
|
+
#
|
486
|
+
# *produces:*
|
487
|
+
#
|
488
|
+
# Added :FOO
|
489
|
+
#
|
490
|
+
def const_added: (Symbol) -> void
|
491
|
+
|
439
492
|
# <!--
|
440
493
|
# rdoc-file=object.c
|
441
494
|
# - mod.const_defined?(sym, inherit=true) -> true or false
|
@@ -911,6 +964,15 @@ class Module < Object
|
|
911
964
|
# C.instance_methods(false) #=> [:method3]
|
912
965
|
# C.instance_methods.include?(:method2) #=> true
|
913
966
|
#
|
967
|
+
# Note that method visibility changes in the current class, as well as aliases,
|
968
|
+
# are considered as methods of the current class by this method:
|
969
|
+
#
|
970
|
+
# class C < B
|
971
|
+
# alias method4 method2
|
972
|
+
# protected :method2
|
973
|
+
# end
|
974
|
+
# C.instance_methods(false).sort #=> [:method2, :method3, :method4]
|
975
|
+
#
|
914
976
|
def instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
915
977
|
|
916
978
|
# <!--
|
@@ -1403,6 +1465,28 @@ class Module < Object
|
|
1403
1465
|
#
|
1404
1466
|
def refine: (Module mod) { () -> void } -> Refinement
|
1405
1467
|
|
1468
|
+
# <!--
|
1469
|
+
# rdoc-file=eval.c
|
1470
|
+
# - refinements -> array
|
1471
|
+
# -->
|
1472
|
+
# Returns an array of modules defined within the receiver.
|
1473
|
+
#
|
1474
|
+
# module A
|
1475
|
+
# refine Integer do
|
1476
|
+
# end
|
1477
|
+
#
|
1478
|
+
# refine String do
|
1479
|
+
# end
|
1480
|
+
# end
|
1481
|
+
#
|
1482
|
+
# p A.refinements
|
1483
|
+
#
|
1484
|
+
# *produces:*
|
1485
|
+
#
|
1486
|
+
# [#<refinement:Integer@A>, #<refinement:String@A>]
|
1487
|
+
#
|
1488
|
+
def refinements: () -> Array[Refinement]
|
1489
|
+
|
1406
1490
|
# <!--
|
1407
1491
|
# rdoc-file=object.c
|
1408
1492
|
# - remove_class_variable(sym) -> obj
|
@@ -1509,6 +1593,15 @@ class Module < Object
|
|
1509
1593
|
#
|
1510
1594
|
def undef_method: (*Symbol | String arg0) -> self
|
1511
1595
|
|
1596
|
+
# <!--
|
1597
|
+
# rdoc-file=object.c
|
1598
|
+
# - mod.undefined_instance_methods -> array
|
1599
|
+
# -->
|
1600
|
+
# Returns a list of the undefined instance methods defined in *mod*. The
|
1601
|
+
# undefined methods of any ancestors are not included.
|
1602
|
+
#
|
1603
|
+
def undefined_instance_methods: () -> Array[Symbol]
|
1604
|
+
|
1512
1605
|
# <!--
|
1513
1606
|
# rdoc-file=eval.c
|
1514
1607
|
# - using(module) -> self
|
data/core/nil_class.rbs
CHANGED
data/core/numeric.rbs
CHANGED
@@ -74,162 +74,90 @@
|
|
74
74
|
#
|
75
75
|
# First, what's elsewhere. Class Numeric:
|
76
76
|
#
|
77
|
-
# * Inherits from [class
|
78
|
-
#
|
79
|
-
# * Includes [module
|
80
|
-
# Comparable](Comparable.html#module-Comparable-label-What-27s+Here).
|
77
|
+
# * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
|
78
|
+
# * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
|
81
79
|
#
|
82
80
|
#
|
83
81
|
# Here, class Numeric provides methods for:
|
84
82
|
#
|
85
|
-
# * [Querying](
|
86
|
-
# * [Comparing](
|
87
|
-
# * [Converting](
|
88
|
-
# * [Other](
|
83
|
+
# * [Querying](rdoc-ref:Numeric@Querying)
|
84
|
+
# * [Comparing](rdoc-ref:Numeric@Comparing)
|
85
|
+
# * [Converting](rdoc-ref:Numeric@Converting)
|
86
|
+
# * [Other](rdoc-ref:Numeric@Other)
|
89
87
|
#
|
90
88
|
#
|
91
89
|
# ### Querying
|
92
90
|
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
# #negative?
|
104
|
-
# : Returns whether `self` is negative.
|
105
|
-
#
|
106
|
-
# #nonzero?
|
107
|
-
# : Returns whether `self` is not zero.
|
108
|
-
#
|
109
|
-
# #positive?
|
110
|
-
# : Returns whether `self` is positive.
|
111
|
-
#
|
112
|
-
# #real?
|
113
|
-
# : Returns whether `self` is a real value.
|
114
|
-
#
|
115
|
-
# #zero?
|
116
|
-
# : Returns whether `self` is zero.
|
117
|
-
#
|
91
|
+
# * #finite?: Returns true unless `self` is infinite or not a number.
|
92
|
+
# * #infinite?: Returns -1, `nil` or +1, depending on whether `self` is
|
93
|
+
# `-Infinity<tt>, finite, or <tt>+Infinity`.
|
94
|
+
# * #integer?: Returns whether `self` is an integer.
|
95
|
+
# * #negative?: Returns whether `self` is negative.
|
96
|
+
# * #nonzero?: Returns whether `self` is not zero.
|
97
|
+
# * #positive?: Returns whether `self` is positive.
|
98
|
+
# * #real?: Returns whether `self` is a real value.
|
99
|
+
# * #zero?: Returns whether `self` is zero.
|
118
100
|
#
|
119
101
|
#
|
120
102
|
# ### Comparing
|
121
103
|
#
|
122
|
-
#
|
123
|
-
# : Returns:
|
104
|
+
# * #<=>: Returns:
|
124
105
|
#
|
125
106
|
# * -1 if `self` is less than the given value.
|
126
107
|
# * 0 if `self` is equal to the given value.
|
127
108
|
# * 1 if `self` is greater than the given value.
|
128
109
|
# * `nil` if `self` and the given value are not comparable.
|
129
110
|
#
|
130
|
-
# #eql?
|
131
|
-
# : Returns whether `self` and the given value have the same value and
|
132
|
-
# type.
|
133
111
|
#
|
112
|
+
# * #eql?: Returns whether `self` and the given value have the same value and
|
113
|
+
# type.
|
134
114
|
#
|
135
115
|
#
|
136
116
|
# ### Converting
|
137
117
|
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
# :
|
143
|
-
#
|
144
|
-
#
|
145
|
-
# :
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
# :
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
#
|
163
|
-
#
|
164
|
-
#
|
165
|
-
# :
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
# :
|
174
|
-
# given divisor.
|
175
|
-
#
|
176
|
-
# #fdiv
|
177
|
-
# : Returns the Float result of dividing `self` by the given divisor.
|
178
|
-
#
|
179
|
-
# #floor
|
180
|
-
# : Returns the largest number less than or equal to `self`, to a given
|
181
|
-
# precision.
|
182
|
-
#
|
183
|
-
# #i
|
184
|
-
# : Returns the Complex object `Complex(0, self)`. the given value.
|
185
|
-
#
|
186
|
-
# #imaginary (aliased as #imag)
|
187
|
-
# : Returns the imaginary part of the `self`.
|
188
|
-
#
|
189
|
-
# #numerator
|
190
|
-
# : Returns the numerator of the Rational representation of `self`; has
|
191
|
-
# the same sign as `self`.
|
192
|
-
#
|
193
|
-
# #polar
|
194
|
-
# : Returns the array `[self.abs, self.arg]`.
|
195
|
-
#
|
196
|
-
# #quo
|
197
|
-
# : Returns the value of `self` divided by the given value.
|
198
|
-
#
|
199
|
-
# #real
|
200
|
-
# : Returns the real part of `self`.
|
201
|
-
#
|
202
|
-
# #rect (aliased as #rectangular)
|
203
|
-
# : Returns the array `[self, 0]`.
|
204
|
-
#
|
205
|
-
# #remainder
|
206
|
-
# : Returns `self-arg*(self/arg).truncate` for the given `arg`.
|
207
|
-
#
|
208
|
-
# #round
|
209
|
-
# : Returns the value of `self` rounded to the nearest value for the given
|
210
|
-
# a precision.
|
211
|
-
#
|
212
|
-
# #to_c
|
213
|
-
# : Returns the Complex representation of `self`.
|
214
|
-
#
|
215
|
-
# #to_int
|
216
|
-
# : Returns the Integer representation of `self`, truncating if necessary.
|
217
|
-
#
|
218
|
-
# #truncate
|
219
|
-
# : Returns `self` truncated (toward zero) to a given precision.
|
220
|
-
#
|
118
|
+
# * #% (aliased as #modulo): Returns the remainder of `self` divided by the
|
119
|
+
# given value.
|
120
|
+
# * #-@: Returns the value of `self`, negated.
|
121
|
+
# * #abs (aliased as #magnitude): Returns the absolute value of `self`.
|
122
|
+
# * #abs2: Returns the square of `self`.
|
123
|
+
# * #angle (aliased as #arg and #phase): Returns 0 if `self` is positive,
|
124
|
+
# Math::PI otherwise.
|
125
|
+
# * #ceil: Returns the smallest number greater than or equal to `self`, to a
|
126
|
+
# given precision.
|
127
|
+
# * #coerce: Returns array `[coerced_self, coerced_other]` for the given other
|
128
|
+
# value.
|
129
|
+
# * #conj (aliased as #conjugate): Returns the complex conjugate of `self`.
|
130
|
+
# * #denominator: Returns the denominator (always positive) of the Rational
|
131
|
+
# representation of `self`.
|
132
|
+
# * #div: Returns the value of `self` divided by the given value and converted
|
133
|
+
# to an integer.
|
134
|
+
# * #divmod: Returns array `[quotient, modulus]` resulting from dividing
|
135
|
+
# `self` the given divisor.
|
136
|
+
# * #fdiv: Returns the Float result of dividing `self` by the given divisor.
|
137
|
+
# * #floor: Returns the largest number less than or equal to `self`, to a
|
138
|
+
# given precision.
|
139
|
+
# * #i: Returns the Complex object `Complex(0, self)`. the given value.
|
140
|
+
# * #imaginary (aliased as #imag): Returns the imaginary part of the `self`.
|
141
|
+
# * #numerator: Returns the numerator of the Rational representation of
|
142
|
+
# `self`; has the same sign as `self`.
|
143
|
+
# * #polar: Returns the array `[self.abs, self.arg]`.
|
144
|
+
# * #quo: Returns the value of `self` divided by the given value.
|
145
|
+
# * #real: Returns the real part of `self`.
|
146
|
+
# * #rect (aliased as #rectangular): Returns the array `[self, 0]`.
|
147
|
+
# * #remainder: Returns `self-arg*(self/arg).truncate` for the given `arg`.
|
148
|
+
# * #round: Returns the value of `self` rounded to the nearest value for the
|
149
|
+
# given a precision.
|
150
|
+
# * #to_c: Returns the Complex representation of `self`.
|
151
|
+
# * #to_int: Returns the Integer representation of `self`, truncating if
|
152
|
+
# necessary.
|
153
|
+
# * #truncate: Returns `self` truncated (toward zero) to a given precision.
|
221
154
|
#
|
222
155
|
#
|
223
156
|
# ### Other
|
224
157
|
#
|
225
|
-
#
|
226
|
-
# :
|
227
|
-
#
|
228
|
-
# #dup (aliased as #+@)
|
229
|
-
# : Returns `self`.
|
230
|
-
#
|
231
|
-
# #step
|
232
|
-
# : Invokes the given block with the sequence of specified numbers.
|
158
|
+
# * #clone: Returns `self`; does not allow freezing.
|
159
|
+
# * #dup (aliased as #+@): Returns `self`.
|
160
|
+
# * #step: Invokes the given block with the sequence of specified numbers.
|
233
161
|
#
|
234
162
|
class Numeric
|
235
163
|
include Comparable
|
@@ -247,9 +175,9 @@ class Numeric
|
|
247
175
|
#
|
248
176
|
# For Rational `r` and real number `n`, these expressions are equivalent:
|
249
177
|
#
|
250
|
-
#
|
251
|
-
#
|
252
|
-
#
|
178
|
+
# r % n
|
179
|
+
# r-n*(r/n).floor
|
180
|
+
# r.divmod(n)[1]
|
253
181
|
#
|
254
182
|
# See Numeric#divmod.
|
255
183
|
#
|
@@ -392,13 +320,15 @@ class Numeric
|
|
392
320
|
#
|
393
321
|
def coerce: (Numeric) -> [ Numeric, Numeric ]
|
394
322
|
|
395
|
-
# <!--
|
396
|
-
#
|
323
|
+
# <!--
|
324
|
+
# rdoc-file=numeric.rb
|
325
|
+
# - conj()
|
326
|
+
# -->
|
397
327
|
#
|
398
328
|
def conj: () -> Numeric
|
399
329
|
|
400
330
|
# <!--
|
401
|
-
# rdoc-file=
|
331
|
+
# rdoc-file=numeric.rb
|
402
332
|
# - num.conj -> self
|
403
333
|
# - num.conjugate -> self
|
404
334
|
# -->
|
@@ -422,8 +352,8 @@ class Numeric
|
|
422
352
|
# `/` in the derived class of `self`. (Numeric itself does not define method
|
423
353
|
# `/`.)
|
424
354
|
#
|
425
|
-
# Of the Core and Standard Library classes, Float
|
426
|
-
#
|
355
|
+
# Of the Core and Standard Library classes, Only Float and Rational use this
|
356
|
+
# implementation.
|
427
357
|
#
|
428
358
|
def div: (Numeric) -> Integer
|
429
359
|
|
@@ -524,13 +454,15 @@ class Numeric
|
|
524
454
|
#
|
525
455
|
def i: () -> Complex
|
526
456
|
|
527
|
-
# <!--
|
528
|
-
#
|
457
|
+
# <!--
|
458
|
+
# rdoc-file=numeric.rb
|
459
|
+
# - imag()
|
460
|
+
# -->
|
529
461
|
#
|
530
462
|
def imag: () -> Numeric
|
531
463
|
|
532
464
|
# <!--
|
533
|
-
# rdoc-file=
|
465
|
+
# rdoc-file=numeric.rb
|
534
466
|
# - num.imag -> 0
|
535
467
|
# - num.imaginary -> 0
|
536
468
|
# -->
|
@@ -577,9 +509,9 @@ class Numeric
|
|
577
509
|
#
|
578
510
|
# For Rational `r` and real number `n`, these expressions are equivalent:
|
579
511
|
#
|
580
|
-
#
|
581
|
-
#
|
582
|
-
#
|
512
|
+
# r % n
|
513
|
+
# r-n*(r/n).floor
|
514
|
+
# r.divmod(n)[1]
|
583
515
|
#
|
584
516
|
# See Numeric#divmod.
|
585
517
|
#
|
@@ -667,7 +599,7 @@ class Numeric
|
|
667
599
|
def quo: (Numeric) -> Numeric
|
668
600
|
|
669
601
|
# <!--
|
670
|
-
# rdoc-file=
|
602
|
+
# rdoc-file=numeric.rb
|
671
603
|
# - num.real -> self
|
672
604
|
# -->
|
673
605
|
# Returns self.
|