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,424 +0,0 @@
|
|
1
|
-
# A rational number can be represented as a pair of integer numbers: a/b (b>0),
|
2
|
-
# where a is the numerator and b is the denominator. Integer a equals rational
|
3
|
-
# a/1 mathematically.
|
4
|
-
#
|
5
|
-
# In Ruby, you can create rational objects with the Kernel#Rational, to_r, or
|
6
|
-
# rationalize methods or by suffixing `r` to a literal. The return values will
|
7
|
-
# be irreducible fractions.
|
8
|
-
#
|
9
|
-
# Rational(1) #=> (1/1)
|
10
|
-
# Rational(2, 3) #=> (2/3)
|
11
|
-
# Rational(4, -6) #=> (-2/3)
|
12
|
-
# 3.to_r #=> (3/1)
|
13
|
-
# 2/3r #=> (2/3)
|
14
|
-
#
|
15
|
-
# You can also create rational objects from floating-point numbers or strings.
|
16
|
-
#
|
17
|
-
# Rational(0.3) #=> (5404319552844595/18014398509481984)
|
18
|
-
# Rational('0.3') #=> (3/10)
|
19
|
-
# Rational('2/3') #=> (2/3)
|
20
|
-
#
|
21
|
-
# 0.3.to_r #=> (5404319552844595/18014398509481984)
|
22
|
-
# '0.3'.to_r #=> (3/10)
|
23
|
-
# '2/3'.to_r #=> (2/3)
|
24
|
-
# 0.3.rationalize #=> (3/10)
|
25
|
-
#
|
26
|
-
# A rational object is an exact number, which helps you to write programs
|
27
|
-
# without any rounding errors.
|
28
|
-
#
|
29
|
-
# 10.times.inject(0) {|t| t + 0.1 } #=> 0.9999999999999999
|
30
|
-
# 10.times.inject(0) {|t| t + Rational('0.1') } #=> (1/1)
|
31
|
-
#
|
32
|
-
# However, when an expression includes an inexact component (numerical value or
|
33
|
-
# operation), it will produce an inexact result.
|
34
|
-
#
|
35
|
-
# Rational(10) / 3 #=> (10/3)
|
36
|
-
# Rational(10) / 3.0 #=> 3.3333333333333335
|
37
|
-
#
|
38
|
-
# Rational(-8) ** Rational(1, 3)
|
39
|
-
# #=> (1.0000000000000002+1.7320508075688772i)
|
40
|
-
#
|
41
|
-
class Rational < Numeric
|
42
|
-
public
|
43
|
-
|
44
|
-
def %: (Integer) -> Rational
|
45
|
-
| (Float) -> Float
|
46
|
-
| (Rational) -> Rational
|
47
|
-
| (Numeric) -> Numeric
|
48
|
-
|
49
|
-
# Performs multiplication.
|
50
|
-
#
|
51
|
-
# Rational(2, 3) * Rational(2, 3) #=> (4/9)
|
52
|
-
# Rational(900) * Rational(1) #=> (900/1)
|
53
|
-
# Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
|
54
|
-
# Rational(9, 8) * 4 #=> (9/2)
|
55
|
-
# Rational(20, 9) * 9.8 #=> 21.77777777777778
|
56
|
-
#
|
57
|
-
def *: (Float) -> Float
|
58
|
-
| (Complex) -> Complex
|
59
|
-
| (Numeric) -> Numeric
|
60
|
-
|
61
|
-
# Performs exponentiation.
|
62
|
-
#
|
63
|
-
# Rational(2) ** Rational(3) #=> (8/1)
|
64
|
-
# Rational(10) ** -2 #=> (1/100)
|
65
|
-
# Rational(10) ** -2.0 #=> 0.01
|
66
|
-
# Rational(-4) ** Rational(1, 2) #=> (0.0+2.0i)
|
67
|
-
# Rational(1, 2) ** 0 #=> (1/1)
|
68
|
-
# Rational(1, 2) ** 0.0 #=> 1.0
|
69
|
-
#
|
70
|
-
def **: (Complex) -> Complex
|
71
|
-
| (Numeric) -> Numeric
|
72
|
-
|
73
|
-
# Performs addition.
|
74
|
-
#
|
75
|
-
# Rational(2, 3) + Rational(2, 3) #=> (4/3)
|
76
|
-
# Rational(900) + Rational(1) #=> (901/1)
|
77
|
-
# Rational(-2, 9) + Rational(-9, 2) #=> (-85/18)
|
78
|
-
# Rational(9, 8) + 4 #=> (41/8)
|
79
|
-
# Rational(20, 9) + 9.8 #=> 12.022222222222222
|
80
|
-
#
|
81
|
-
def +: (Float) -> Float
|
82
|
-
| (Complex) -> Complex
|
83
|
-
| (Numeric) -> Rational
|
84
|
-
|
85
|
-
def +@: () -> Rational
|
86
|
-
|
87
|
-
# Performs subtraction.
|
88
|
-
#
|
89
|
-
# Rational(2, 3) - Rational(2, 3) #=> (0/1)
|
90
|
-
# Rational(900) - Rational(1) #=> (899/1)
|
91
|
-
# Rational(-2, 9) - Rational(-9, 2) #=> (77/18)
|
92
|
-
# Rational(9, 8) - 4 #=> (-23/8)
|
93
|
-
# Rational(20, 9) - 9.8 #=> -7.577777777777778
|
94
|
-
#
|
95
|
-
def -: (Float) -> Float
|
96
|
-
| (Complex) -> Complex
|
97
|
-
| (Numeric) -> Rational
|
98
|
-
|
99
|
-
# Negates `rat`.
|
100
|
-
#
|
101
|
-
def -@: () -> Rational
|
102
|
-
|
103
|
-
# Performs division.
|
104
|
-
#
|
105
|
-
# Rational(2, 3) / Rational(2, 3) #=> (1/1)
|
106
|
-
# Rational(900) / Rational(1) #=> (900/1)
|
107
|
-
# Rational(-2, 9) / Rational(-9, 2) #=> (4/81)
|
108
|
-
# Rational(9, 8) / 4 #=> (9/32)
|
109
|
-
# Rational(20, 9) / 9.8 #=> 0.22675736961451246
|
110
|
-
#
|
111
|
-
def /: (Float) -> Float
|
112
|
-
| (Complex) -> Complex
|
113
|
-
| (Numeric) -> Rational
|
114
|
-
|
115
|
-
# Returns -1, 0, or +1 depending on whether `rational` is less than, equal to,
|
116
|
-
# or greater than `numeric`.
|
117
|
-
#
|
118
|
-
# `nil` is returned if the two values are incomparable.
|
119
|
-
#
|
120
|
-
# Rational(2, 3) <=> Rational(2, 3) #=> 0
|
121
|
-
# Rational(5) <=> 5 #=> 0
|
122
|
-
# Rational(2, 3) <=> Rational(1, 3) #=> 1
|
123
|
-
# Rational(1, 3) <=> 1 #=> -1
|
124
|
-
# Rational(1, 3) <=> 0.3 #=> 1
|
125
|
-
#
|
126
|
-
# Rational(1, 3) <=> "0.3" #=> nil
|
127
|
-
#
|
128
|
-
def <=>: (Numeric) -> Integer?
|
129
|
-
|
130
|
-
# Returns `true` if `rat` equals `object` numerically.
|
131
|
-
#
|
132
|
-
# Rational(2, 3) == Rational(2, 3) #=> true
|
133
|
-
# Rational(5) == 5 #=> true
|
134
|
-
# Rational(0) == 0.0 #=> true
|
135
|
-
# Rational('1/3') == 0.33 #=> false
|
136
|
-
# Rational('1/2') == '1/2' #=> false
|
137
|
-
#
|
138
|
-
def ==: (untyped) -> bool
|
139
|
-
|
140
|
-
# Returns the absolute value of `rat`.
|
141
|
-
#
|
142
|
-
# (1/2r).abs #=> (1/2)
|
143
|
-
# (-1/2r).abs #=> (1/2)
|
144
|
-
#
|
145
|
-
# Rational#magnitude is an alias for Rational#abs.
|
146
|
-
#
|
147
|
-
def abs: () -> Rational
|
148
|
-
|
149
|
-
def abs2: () -> Rational
|
150
|
-
|
151
|
-
def angle: () -> (Integer | Float)
|
152
|
-
|
153
|
-
alias arg angle
|
154
|
-
|
155
|
-
# Returns the smallest number greater than or equal to `rat` with a precision of
|
156
|
-
# `ndigits` decimal digits (default: 0).
|
157
|
-
#
|
158
|
-
# When the precision is negative, the returned value is an integer with at least
|
159
|
-
# `ndigits.abs` trailing zeros.
|
160
|
-
#
|
161
|
-
# Returns a rational when `ndigits` is positive, otherwise returns an integer.
|
162
|
-
#
|
163
|
-
# Rational(3).ceil #=> 3
|
164
|
-
# Rational(2, 3).ceil #=> 1
|
165
|
-
# Rational(-3, 2).ceil #=> -1
|
166
|
-
#
|
167
|
-
# # decimal - 1 2 3 . 4 5 6
|
168
|
-
# # ^ ^ ^ ^ ^ ^
|
169
|
-
# # precision -3 -2 -1 0 +1 +2
|
170
|
-
#
|
171
|
-
# Rational('-123.456').ceil(+1).to_f #=> -123.4
|
172
|
-
# Rational('-123.456').ceil(-1) #=> -120
|
173
|
-
#
|
174
|
-
def ceil: () -> Integer
|
175
|
-
| (Integer digits) -> (Integer | Rational)
|
176
|
-
|
177
|
-
def clone: (?freeze: bool) -> self
|
178
|
-
|
179
|
-
def coerce: (Numeric) -> [Numeric, Numeric]
|
180
|
-
|
181
|
-
def conj: () -> Rational
|
182
|
-
|
183
|
-
def conjugate: () -> Rational
|
184
|
-
|
185
|
-
# Returns the denominator (always positive).
|
186
|
-
#
|
187
|
-
# Rational(7).denominator #=> 1
|
188
|
-
# Rational(7, 1).denominator #=> 1
|
189
|
-
# Rational(9, -4).denominator #=> 4
|
190
|
-
# Rational(-2, -10).denominator #=> 5
|
191
|
-
#
|
192
|
-
def denominator: () -> Integer
|
193
|
-
|
194
|
-
def div: (Numeric) -> Integer
|
195
|
-
|
196
|
-
def divmod: (Numeric) -> [Numeric, Numeric]
|
197
|
-
|
198
|
-
def dup: () -> self
|
199
|
-
|
200
|
-
def eql?: (untyped) -> bool
|
201
|
-
|
202
|
-
# Performs division and returns the value as a Float.
|
203
|
-
#
|
204
|
-
# Rational(2, 3).fdiv(1) #=> 0.6666666666666666
|
205
|
-
# Rational(2, 3).fdiv(0.5) #=> 1.3333333333333333
|
206
|
-
# Rational(2).fdiv(3) #=> 0.6666666666666666
|
207
|
-
#
|
208
|
-
def fdiv: (Numeric) -> Float
|
209
|
-
|
210
|
-
def finite?: () -> bool
|
211
|
-
|
212
|
-
# Returns the largest number less than or equal to `rat` with a precision of
|
213
|
-
# `ndigits` decimal digits (default: 0).
|
214
|
-
#
|
215
|
-
# When the precision is negative, the returned value is an integer with at least
|
216
|
-
# `ndigits.abs` trailing zeros.
|
217
|
-
#
|
218
|
-
# Returns a rational when `ndigits` is positive, otherwise returns an integer.
|
219
|
-
#
|
220
|
-
# Rational(3).floor #=> 3
|
221
|
-
# Rational(2, 3).floor #=> 0
|
222
|
-
# Rational(-3, 2).floor #=> -2
|
223
|
-
#
|
224
|
-
# # decimal - 1 2 3 . 4 5 6
|
225
|
-
# # ^ ^ ^ ^ ^ ^
|
226
|
-
# # precision -3 -2 -1 0 +1 +2
|
227
|
-
#
|
228
|
-
# Rational('-123.456').floor(+1).to_f #=> -123.5
|
229
|
-
# Rational('-123.456').floor(-1) #=> -130
|
230
|
-
#
|
231
|
-
def floor: () -> Integer
|
232
|
-
| (Integer digits) -> (Integer | Rational)
|
233
|
-
|
234
|
-
def hash: () -> Integer
|
235
|
-
|
236
|
-
def i: () -> Complex
|
237
|
-
|
238
|
-
def imag: () -> Integer
|
239
|
-
|
240
|
-
def imaginary: () -> Integer
|
241
|
-
|
242
|
-
def infinite?: () -> Integer?
|
243
|
-
|
244
|
-
# Returns the value as a string for inspection.
|
245
|
-
#
|
246
|
-
# Rational(2).inspect #=> "(2/1)"
|
247
|
-
# Rational(-8, 6).inspect #=> "(-4/3)"
|
248
|
-
# Rational('1/2').inspect #=> "(1/2)"
|
249
|
-
#
|
250
|
-
def inspect: () -> String
|
251
|
-
|
252
|
-
def integer?: () -> bool
|
253
|
-
|
254
|
-
# Returns the absolute value of `rat`.
|
255
|
-
#
|
256
|
-
# (1/2r).abs #=> (1/2)
|
257
|
-
# (-1/2r).abs #=> (1/2)
|
258
|
-
#
|
259
|
-
# Rational#magnitude is an alias for Rational#abs.
|
260
|
-
#
|
261
|
-
alias magnitude abs
|
262
|
-
|
263
|
-
def modulo: (Float) -> Float
|
264
|
-
| (Numeric) -> Rational
|
265
|
-
|
266
|
-
# Returns `true` if `rat` is less than 0.
|
267
|
-
#
|
268
|
-
def negative?: () -> bool
|
269
|
-
|
270
|
-
def nonzero?: () -> self?
|
271
|
-
|
272
|
-
# Returns the numerator.
|
273
|
-
#
|
274
|
-
# Rational(7).numerator #=> 7
|
275
|
-
# Rational(7, 1).numerator #=> 7
|
276
|
-
# Rational(9, -4).numerator #=> -9
|
277
|
-
# Rational(-2, -10).numerator #=> 1
|
278
|
-
#
|
279
|
-
def numerator: () -> Integer
|
280
|
-
|
281
|
-
alias phase angle
|
282
|
-
|
283
|
-
def polar: () -> [ Rational, Integer | Float ]
|
284
|
-
|
285
|
-
# Returns `true` if `rat` is greater than 0.
|
286
|
-
#
|
287
|
-
def positive?: () -> bool
|
288
|
-
|
289
|
-
# Performs division.
|
290
|
-
#
|
291
|
-
# Rational(2, 3) / Rational(2, 3) #=> (1/1)
|
292
|
-
# Rational(900) / Rational(1) #=> (900/1)
|
293
|
-
# Rational(-2, 9) / Rational(-9, 2) #=> (4/81)
|
294
|
-
# Rational(9, 8) / 4 #=> (9/32)
|
295
|
-
# Rational(20, 9) / 9.8 #=> 0.22675736961451246
|
296
|
-
#
|
297
|
-
def quo: (Float) -> Float
|
298
|
-
| (Complex) -> Complex
|
299
|
-
| (Numeric) -> Rational
|
300
|
-
|
301
|
-
# Returns a simpler approximation of the value if the optional argument `eps` is
|
302
|
-
# given (rat-|eps| <= result <= rat+|eps|), self otherwise.
|
303
|
-
#
|
304
|
-
# r = Rational(5033165, 16777216)
|
305
|
-
# r.rationalize #=> (5033165/16777216)
|
306
|
-
# r.rationalize(Rational('0.01')) #=> (3/10)
|
307
|
-
# r.rationalize(Rational('0.1')) #=> (1/3)
|
308
|
-
#
|
309
|
-
def rationalize: (?Numeric eps) -> Rational
|
310
|
-
|
311
|
-
def real: () -> Rational
|
312
|
-
|
313
|
-
def real?: () -> true
|
314
|
-
|
315
|
-
def rect: () -> [ Rational, Numeric ]
|
316
|
-
|
317
|
-
alias rectangular rect
|
318
|
-
|
319
|
-
def remainder: (Float) -> Float
|
320
|
-
| (Numeric) -> Rational
|
321
|
-
|
322
|
-
# Returns `rat` rounded to the nearest value with a precision of `ndigits`
|
323
|
-
# decimal digits (default: 0).
|
324
|
-
#
|
325
|
-
# When the precision is negative, the returned value is an integer with at least
|
326
|
-
# `ndigits.abs` trailing zeros.
|
327
|
-
#
|
328
|
-
# Returns a rational when `ndigits` is positive, otherwise returns an integer.
|
329
|
-
#
|
330
|
-
# Rational(3).round #=> 3
|
331
|
-
# Rational(2, 3).round #=> 1
|
332
|
-
# Rational(-3, 2).round #=> -2
|
333
|
-
#
|
334
|
-
# # decimal - 1 2 3 . 4 5 6
|
335
|
-
# # ^ ^ ^ ^ ^ ^
|
336
|
-
# # precision -3 -2 -1 0 +1 +2
|
337
|
-
#
|
338
|
-
# Rational('-123.456').round(+1).to_f #=> -123.5
|
339
|
-
# Rational('-123.456').round(-1) #=> -120
|
340
|
-
#
|
341
|
-
# The optional `half` keyword argument is available similar to Float#round.
|
342
|
-
#
|
343
|
-
# Rational(25, 100).round(1, half: :up) #=> (3/10)
|
344
|
-
# Rational(25, 100).round(1, half: :down) #=> (1/5)
|
345
|
-
# Rational(25, 100).round(1, half: :even) #=> (1/5)
|
346
|
-
# Rational(35, 100).round(1, half: :up) #=> (2/5)
|
347
|
-
# Rational(35, 100).round(1, half: :down) #=> (3/10)
|
348
|
-
# Rational(35, 100).round(1, half: :even) #=> (2/5)
|
349
|
-
# Rational(-25, 100).round(1, half: :up) #=> (-3/10)
|
350
|
-
# Rational(-25, 100).round(1, half: :down) #=> (-1/5)
|
351
|
-
# Rational(-25, 100).round(1, half: :even) #=> (-1/5)
|
352
|
-
#
|
353
|
-
def round: (?half: :up | :down | :even) -> Integer
|
354
|
-
| (Integer digits, ?half: :up | :down | :even) -> (Integer | Rational)
|
355
|
-
|
356
|
-
def step: (?Numeric limit, ?Numeric step) { (Rational) -> void } -> self
|
357
|
-
| (?Numeric limit, ?Numeric step) -> Enumerator[Rational, self]
|
358
|
-
| (?by: Numeric, ?to: Numeric) { (Rational) -> void } -> self
|
359
|
-
| (?by: Numeric, ?to: Numeric) -> Enumerator[Rational, self]
|
360
|
-
|
361
|
-
def to_c: () -> Complex
|
362
|
-
|
363
|
-
# Returns the value as a Float.
|
364
|
-
#
|
365
|
-
# Rational(2).to_f #=> 2.0
|
366
|
-
# Rational(9, 4).to_f #=> 2.25
|
367
|
-
# Rational(-3, 4).to_f #=> -0.75
|
368
|
-
# Rational(20, 3).to_f #=> 6.666666666666667
|
369
|
-
#
|
370
|
-
def to_f: () -> Float
|
371
|
-
|
372
|
-
# Returns the truncated value as an integer.
|
373
|
-
#
|
374
|
-
# Equivalent to Rational#truncate.
|
375
|
-
#
|
376
|
-
# Rational(2, 3).to_i #=> 0
|
377
|
-
# Rational(3).to_i #=> 3
|
378
|
-
# Rational(300.6).to_i #=> 300
|
379
|
-
# Rational(98, 71).to_i #=> 1
|
380
|
-
# Rational(-31, 2).to_i #=> -15
|
381
|
-
#
|
382
|
-
def to_i: () -> Integer
|
383
|
-
|
384
|
-
alias to_int to_i
|
385
|
-
|
386
|
-
# Returns self.
|
387
|
-
#
|
388
|
-
# Rational(2).to_r #=> (2/1)
|
389
|
-
# Rational(-8, 6).to_r #=> (-4/3)
|
390
|
-
#
|
391
|
-
def to_r: () -> Rational
|
392
|
-
|
393
|
-
# Returns the value as a string.
|
394
|
-
#
|
395
|
-
# Rational(2).to_s #=> "2/1"
|
396
|
-
# Rational(-8, 6).to_s #=> "-4/3"
|
397
|
-
# Rational('1/2').to_s #=> "1/2"
|
398
|
-
#
|
399
|
-
def to_s: () -> String
|
400
|
-
|
401
|
-
# Returns `rat` truncated (toward zero) to a precision of `ndigits` decimal
|
402
|
-
# digits (default: 0).
|
403
|
-
#
|
404
|
-
# When the precision is negative, the returned value is an integer with at least
|
405
|
-
# `ndigits.abs` trailing zeros.
|
406
|
-
#
|
407
|
-
# Returns a rational when `ndigits` is positive, otherwise returns an integer.
|
408
|
-
#
|
409
|
-
# Rational(3).truncate #=> 3
|
410
|
-
# Rational(2, 3).truncate #=> 0
|
411
|
-
# Rational(-3, 2).truncate #=> -1
|
412
|
-
#
|
413
|
-
# # decimal - 1 2 3 . 4 5 6
|
414
|
-
# # ^ ^ ^ ^ ^ ^
|
415
|
-
# # precision -3 -2 -1 0 +1 +2
|
416
|
-
#
|
417
|
-
# Rational('-123.456').truncate(+1).to_f #=> -123.4
|
418
|
-
# Rational('-123.456').truncate(-1) #=> -120
|
419
|
-
#
|
420
|
-
def truncate: () -> Integer
|
421
|
-
| (Integer ndigits) -> (Integer | Rational)
|
422
|
-
|
423
|
-
def zero?: () -> bool
|
424
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# The module storing Ruby interpreter configurations on building.
|
2
|
-
#
|
3
|
-
# This file was created by mkconfig.rb when ruby was built. It contains build
|
4
|
-
# information for ruby which is used e.g. by mkmf to build compatible native
|
5
|
-
# extensions. Any changes made to this file will be lost the next time ruby is
|
6
|
-
# built.
|
7
|
-
#
|
8
|
-
module RbConfig
|
9
|
-
# expands variable with given `val` value.
|
10
|
-
#
|
11
|
-
# RbConfig.expand("$(bindir)") # => /home/foobar/all-ruby/ruby19x/bin
|
12
|
-
#
|
13
|
-
def self.expand: (String val, ?Hash[String, String] config) -> String
|
14
|
-
|
15
|
-
def self.fire_update!: (String key, String val, ?Hash[String, String] mkconf, ?Hash[String, String] conf) -> Array[String]?
|
16
|
-
|
17
|
-
def self.ruby: () -> String
|
18
|
-
end
|
19
|
-
|
20
|
-
# The hash configurations stored.
|
21
|
-
#
|
22
|
-
RbConfig::CONFIG: Hash[String, String]
|
23
|
-
|
24
|
-
# DESTDIR on make install.
|
25
|
-
#
|
26
|
-
RbConfig::DESTDIR: String
|
27
|
-
|
28
|
-
# Almost same with CONFIG. MAKEFILE_CONFIG has other variable reference like
|
29
|
-
# below.
|
30
|
-
#
|
31
|
-
# MAKEFILE_CONFIG["bindir"] = "$(exec_prefix)/bin"
|
32
|
-
#
|
33
|
-
# The values of this constant is used for creating Makefile.
|
34
|
-
#
|
35
|
-
# require 'rbconfig'
|
36
|
-
#
|
37
|
-
# print <<-END_OF_MAKEFILE
|
38
|
-
# prefix = #{Config::MAKEFILE_CONFIG['prefix']}
|
39
|
-
# exec_prefix = #{Config::MAKEFILE_CONFIG['exec_prefix']}
|
40
|
-
# bindir = #{Config::MAKEFILE_CONFIG['bindir']}
|
41
|
-
# END_OF_MAKEFILE
|
42
|
-
#
|
43
|
-
# => prefix = /usr/local
|
44
|
-
# exec_prefix = $(prefix)
|
45
|
-
# bindir = $(exec_prefix)/bin MAKEFILE_CONFIG = {}
|
46
|
-
#
|
47
|
-
# RbConfig.expand is used for resolving references like above in rbconfig.
|
48
|
-
#
|
49
|
-
# require 'rbconfig'
|
50
|
-
# p Config.expand(Config::MAKEFILE_CONFIG["bindir"])
|
51
|
-
# # => "/usr/local/bin"
|
52
|
-
#
|
53
|
-
RbConfig::MAKEFILE_CONFIG: Hash[String, String]
|
54
|
-
|
55
|
-
# Ruby installed directory.
|
56
|
-
#
|
57
|
-
RbConfig::TOPDIR: String
|