Class: AndNode
Overview
Logic Gate Nodes
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(lhs, rhs) ⇒ AndNode
constructor
A new instance of AndNode.
- #to_s ⇒ Object
Constructor Details
#initialize(lhs, rhs) ⇒ AndNode
Returns a new instance of AndNode.
94 95 96 97 98 99 |
# File 'lib/nodes/basenodes.rb', line 94 def initialize(lhs, rhs) @lhs, @rhs = lhs, rhs return unless @rhs.class.method_defined?(:lhs) @rhs.lhs = @lhs.lhs if @rhs.lhs == nil end |
Instance Method Details
#evaluate ⇒ Object
105 106 107 |
# File 'lib/nodes/basenodes.rb', line 105 def evaluate @lhs.evaluate && @rhs.evaluate end |
#to_s ⇒ Object
101 102 103 |
# File 'lib/nodes/basenodes.rb', line 101 def to_s "#{@lhs} and #{@rhs}" end |