Class: Keisan::AST::ConstantLiteral
Instance Method Summary
collapse
Methods inherited from Node
#coerce, #contains_a?, #deep_dup, #differentiate, #differentiated, #evaluate_assignments, #evaluated, #false?, #replace, #replaced, #simplified, #simplify, #to_cell, #to_node, #traverse, #true?, #unbound_functions, #unbound_variables, #value, #well_defined?
Instance Method Details
#%(other) ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/keisan/ast/constant_literal.rb', line 62
def %(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot modulo #{self.class} and #{other.class}")
else
super
end
end
|
#&(other) ⇒ Object
94
95
96
97
98
99
100
|
# File 'lib/keisan/ast/constant_literal.rb', line 94
def &(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot bitwise and #{self.class} and #{other.class}")
else
super
end
end
|
#*(other) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/keisan/ast/constant_literal.rb', line 46
def *(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot multiply #{self.class} and #{other.class}")
else
super
end
end
|
#**(other) ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/keisan/ast/constant_literal.rb', line 86
def **(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot exponentiate #{self.class} and #{other.class}")
else
super
end
end
|
#+(other) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/keisan/ast/constant_literal.rb', line 30
def +(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot add #{self.class} to #{other.class}")
else
super
end
end
|
#-(other) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/keisan/ast/constant_literal.rb', line 38
def -(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot subtract #{self.class} from #{other.class}")
else
super
end
end
|
#/(other) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/keisan/ast/constant_literal.rb', line 54
def /(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot divide #{self.class} and #{other.class}")
else
super
end
end
|
#<(other) ⇒ Object
150
151
152
153
154
155
156
|
# File 'lib/keisan/ast/constant_literal.rb', line 150
def <(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot compute #{self.class} < #{other.class}")
else
super
end
end
|
#<<(other) ⇒ Object
118
119
120
121
122
123
124
|
# File 'lib/keisan/ast/constant_literal.rb', line 118
def <<(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot bitwise left shift #{self.class} and #{other.class}")
else
super
end
end
|
#<=(other) ⇒ Object
158
159
160
161
162
163
164
|
# File 'lib/keisan/ast/constant_literal.rb', line 158
def <=(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot compute #{self.class} <= #{other.class}")
else
super
end
end
|
#==(other) ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/keisan/ast/constant_literal.rb', line 8
def ==(other)
case other
when ConstantLiteral
value == other.value
else
false
end
end
|
#>(other) ⇒ Object
134
135
136
137
138
139
140
|
# File 'lib/keisan/ast/constant_literal.rb', line 134
def >(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot compute #{self.class} > #{other.class}")
else
super
end
end
|
#>=(other) ⇒ Object
142
143
144
145
146
147
148
|
# File 'lib/keisan/ast/constant_literal.rb', line 142
def >=(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot compute #{self.class} >= #{other.class}")
else
super
end
end
|
#>>(other) ⇒ Object
126
127
128
129
130
131
132
|
# File 'lib/keisan/ast/constant_literal.rb', line 126
def >>(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot bitwise right shift #{self.class} and #{other.class}")
else
super
end
end
|
#^(other) ⇒ Object
102
103
104
105
106
107
108
|
# File 'lib/keisan/ast/constant_literal.rb', line 102
def ^(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot bitwise xor #{self.class} and #{other.class}")
else
super
end
end
|
#and(other) ⇒ Object
174
175
176
177
178
179
180
|
# File 'lib/keisan/ast/constant_literal.rb', line 174
def and(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot logical and #{self.class} and #{other.class}")
else
super
end
end
|
#equal(other) ⇒ Object
166
167
168
|
# File 'lib/keisan/ast/constant_literal.rb', line 166
def equal(other)
other.is_constant? ? Boolean.new(false) : super
end
|
#evaluate(context = nil) ⇒ Object
4
5
6
|
# File 'lib/keisan/ast/constant_literal.rb', line 4
def evaluate(context = nil)
self
end
|
#is_constant? ⇒ Boolean
26
27
28
|
# File 'lib/keisan/ast/constant_literal.rb', line 26
def is_constant?
true
end
|
#not_equal(other) ⇒ Object
170
171
172
|
# File 'lib/keisan/ast/constant_literal.rb', line 170
def not_equal(other)
other.is_constant? ? Boolean.new(true) : super
end
|
#or(other) ⇒ Object
182
183
184
185
186
187
188
|
# File 'lib/keisan/ast/constant_literal.rb', line 182
def or(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot logical or #{self.class} and #{other.class}")
else
super
end
end
|
#to_s ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/keisan/ast/constant_literal.rb', line 17
def to_s
case value
when Rational
"(#{value.to_s})"
else
value.to_s
end
end
|
#|(other) ⇒ Object
110
111
112
113
114
115
116
|
# File 'lib/keisan/ast/constant_literal.rb', line 110
def |(other)
if other.is_constant?
raise Keisan::Exceptions::InvalidExpression.new("Cannot bitwise or #{self.class} and #{other.class}")
else
super
end
end
|