Class: MathEngine::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#leftObject (readonly) Also known as: value

Returns the value of attribute left.



3
4
5
# File 'lib/nodes.rb', line 3

def left
  @left
end

#rightObject (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