Class: De::Boolean::BooleanOperator

Inherits:
Operator show all
Includes:
Bn, SymmetricOperator
Defined in:
lib/de/boolean/operator.rb

Overview

Class representing Boolean operator Base abstract class for concrete operators AND, OR, NOT

Direct Known Subclasses

And, Not, Or

Instance Attribute Summary

Attributes inherited from Tree::TreeNode

#name

Instance Method Summary collapse

Methods included from SymmetricOperator

#==, #hash

Methods inherited from Operator

#==, #hash, #valid?

Methods inherited from Expression

#copy, #eql?, #evaluate, #hash, #to_s, #valid?

Constructor Details

#initialize(name, content, operands = nil) ⇒ BooleanOperator

Constructor. Prevents direct BooleanOperator class objects creation

Input

name<String>

operands<Array>

(optional) array of Operand objects.

If given they are added as children to current operator

Raises:

  • (Error::AbstractClassObjectCreationError)


39
40
41
42
# File 'lib/de/boolean/operator.rb', line 39

def initialize(name, content, operands = nil)
  raise Error::AbstractClassObjectCreationError if instance_of? BooleanOperator
  super(name, content, operands)
end

Instance Method Details

#<<(obj) ⇒ Object

Adds boolean operator or operand as a child to boolean operator

Raises:

  • (Error::TypeError)


47
48
49
50
# File 'lib/de/boolean/operator.rb', line 47

def <<(obj)
  raise Error::TypeError unless obj.is_a?(De::Boolean::Bn)
  super(obj)
end