Class: CompareNode

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

Overview

Operation Nodes

Instance Attribute Summary collapse

Attributes inherited from Node

#value

Instance Method Summary collapse

Methods inherited from Node

#to_s

Constructor Details

#initialize(lhs, op, rhs) ⇒ CompareNode

Returns a new instance of CompareNode.



91
92
93
# File 'lib/nodes/basenodes.rb', line 91

def initialize(lhs, op, rhs)
  @lhs, @op, @rhs = lhs, op, rhs
end

Instance Attribute Details

#lhsObject

Returns the value of attribute lhs.



89
90
91
# File 'lib/nodes/basenodes.rb', line 89

def lhs
  @lhs
end

#opObject

Returns the value of attribute op.



89
90
91
# File 'lib/nodes/basenodes.rb', line 89

def op
  @op
end

#rhsObject

Returns the value of attribute rhs.



89
90
91
# File 'lib/nodes/basenodes.rb', line 89

def rhs
  @rhs
end

Instance Method Details

#evaluateObject



95
96
97
# File 'lib/nodes/basenodes.rb', line 95

def evaluate
  @value = @lhs.evaluate.send(@op, @rhs.evaluate)
end