Class: AndNode

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

Overview

Logic Gate Nodes

Instance Attribute Summary

Attributes inherited from Node

#value

Instance Method Summary collapse

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

#evaluateObject



105
106
107
# File 'lib/nodes/basenodes.rb', line 105

def evaluate
  @lhs.evaluate && @rhs.evaluate
end

#to_sObject



101
102
103
# File 'lib/nodes/basenodes.rb', line 101

def to_s
  "#{@lhs} and #{@rhs}"
end