Class: ExaltedMath::Node::Operator
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(left, right) ⇒ Operator
Returns a new instance of Operator.
8
9
10
11
|
# File 'lib/exalted_math/node/operator.rb', line 8
def initialize(left, right)
@left = left
@right = right
end
|
Instance Attribute Details
#left ⇒ Object
Returns the value of attribute left.
6
7
8
|
# File 'lib/exalted_math/node/operator.rb', line 6
def left
@left
end
|
#right ⇒ Object
Returns the value of attribute right.
6
7
8
|
# File 'lib/exalted_math/node/operator.rb', line 6
def right
@right
end
|
Instance Method Details
#==(o) ⇒ Object
29
30
31
32
|
# File 'lib/exalted_math/node/operator.rb', line 29
def ==(o)
return false unless self.class === o
left == o.left && right == o.right
end
|
#constant? ⇒ Boolean
13
14
15
|
# File 'lib/exalted_math/node/operator.rb', line 13
def constant?
left.constant? and right.constant?
end
|
#simplify ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/exalted_math/node/operator.rb', line 21
def simplify
if constant?
Number.new(value)
else
self.class.new(left.simplify, right.simplify)
end
end
|
#valid?(stats = []) ⇒ Boolean
34
35
36
|
# File 'lib/exalted_math/node/operator.rb', line 34
def valid?(stats=[])
left.valid?(stats) && right.valid?(stats)
end
|
#value(context = {}) ⇒ Object
17
18
19
|
# File 'lib/exalted_math/node/operator.rb', line 17
def value(context={})
raise NotImplementedError
end
|