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.



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

#evaluateObject



64
65
66
# File 'lib/nodes/basenodes.rb', line 64

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

#to_sObject



60
61
62
# File 'lib/nodes/basenodes.rb', line 60

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