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.
51 52 53 54 55 56 57 58 |
# File 'lib/nodes/basenodes.rb', line 51 def initialize(lhs, rhs) @lhs, @rhs = lhs, rhs if @rhs.class.method_defined? (:lhs) if @rhs.lhs == nil @rhs.lhs = @lhs.lhs end end end |
Instance Method Details
#evaluate ⇒ Object
64 65 66 |
# File 'lib/nodes/basenodes.rb', line 64 def evaluate @lhs.evaluate && @rhs.evaluate end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/nodes/basenodes.rb', line 60 def to_s "#{@lhs} and #{@rhs}" end |