Class: MathEngine::Node
- Inherits:
-
Object
- Object
- MathEngine::Node
- Defined in:
- lib/nodes.rb
Direct Known Subclasses
AdditionNode, AssignmentNode, DivisionNode, ExponentNode, ExpressionNode, FunctionCallNode, IdentifierNode, LiteralNumberNode, ModulusNode, MultiplicationNode, ParametersNode, SubtractionNode
Instance Attribute Summary collapse
-
#left ⇒ Object
(also: #value)
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
- #evaluate(evaluator) ⇒ Object
-
#initialize(left, right = nil) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(left, right = nil) ⇒ Node
Returns a new instance of Node.
6 7 8 |
# File 'lib/nodes.rb', line 6 def initialize(left, right = nil) @left, @right = left, right end |
Instance Attribute Details
#left ⇒ Object (readonly) Also known as: value
Returns the value of attribute left.
3 4 5 |
# File 'lib/nodes.rb', line 3 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
3 4 5 |
# File 'lib/nodes.rb', line 3 def right @right end |
Instance Method Details
#evaluate(evaluator) ⇒ Object
10 11 12 |
# File 'lib/nodes.rb', line 10 def evaluate(evaluator) evaluator.send(method_name, self) end |