-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathtrue_class.rbs
99 lines (93 loc) · 2.23 KB
/
true_class.rbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# <!-- rdoc-file=object.c -->
# The class of the singleton object `true`.
#
# Several of its methods act as operators:
#
# * #&
# * #|
# * #===
# * #^
#
#
# One other method:
#
# * #to_s and its alias #inspect.
#
class TrueClass
def !: () -> false
# <!--
# rdoc-file=object.c
# - true & object -> true or false
# -->
# Returns `false` if `object` is `false` or `nil`, `true` otherwise:
#
# true & Object.new # => true true & false # => false true & nil #
# => false
#
def &: (false | nil) -> false
| (untyped obj) -> bool
# <!--
# rdoc-file=object.c
# - true === other -> true or false
# - false === other -> true or false
# - nil === other -> true or false
# -->
# Returns `true` or `false`.
#
# Like Object#==, if `object` is an instance of Object (and not an instance of
# one of its many subclasses).
#
# This method is commonly overridden by those subclasses, to provide meaningful
# semantics in `case` statements.
#
def ===: (true) -> true
| (untyped obj) -> bool
# <!--
# rdoc-file=object.c
# - true ^ object -> !object
# -->
# Returns `true` if `object` is `false` or `nil`, `false` otherwise:
#
# true ^ Object.new # => false
# true ^ false # => true
# true ^ nil # => true
#
def ^: (false | nil) -> true
| (untyped obj) -> bool
# <!-- rdoc-file=object.c -->
# Returns string `'true'`:
#
# true.to_s # => "true"
#
# TrueClass#inspect is an alias for TrueClass#to_s.
#
alias inspect to_s
# <!--
# rdoc-file=object.c
# - true.to_s -> 'true'
# -->
# Returns string `'true'`:
#
# true.to_s # => "true"
#
# TrueClass#inspect is an alias for TrueClass#to_s.
#
def to_s: () -> "true"
# <!--
# rdoc-file=object.c
# - true | object -> true
# -->
# Returns `true`:
#
# true | Object.new # => true
# true | false # => true
# true | nil # => true
#
# Argument `object` is evaluated. This is different from `true` with the
# short-circuit operator, whose operand is evaluated only if necessary:
#
# true | raise # => Raises RuntimeError.
# true || raise # => true
#
def |: (untyped obj) -> true
end