Class: LogicTools::NodeUnary

Inherits:
Node
  • Object
show all
Defined in:
lib/logic_tools/logictree.rb

Overview

Represents an unary node.

Direct Known Subclasses

NodeNot

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#distribute, #each_line, #each_maxterm, #each_minterm, #eql?, #flatten, #flatten_deep, #getVariables, #hash, #inspect, #simplify, #to_std_conjunctive, #to_std_disjunctive, #to_sum_product

Constructor Details

#initialize(op, child) ⇒ NodeUnary

Creates a node with operator op and a child.



696
697
698
699
700
701
702
703
# File 'lib/logic_tools/logictree.rb', line 696

def initialize(op,child)
    if !child.is_a?(Node) then
        raise ArgumentError.new("Not a valid object for child.")
    end
    @op = op.to_sym
    @child = child
    @sym = self.to_s.to_sym
end

Instance Attribute Details

#childObject (readonly)

Returns the value of attribute child.



693
694
695
# File 'lib/logic_tools/logictree.rb', line 693

def child
  @child
end

#opObject (readonly)

Returns the value of attribute op.



693
694
695
# File 'lib/logic_tools/logictree.rb', line 693

def op
  @op
end

Instance Method Details

#==(node) ⇒ Object

Compares with node.



734
735
736
737
738
# File 'lib/logic_tools/logictree.rb', line 734

def ==(node) # :nodoc:
    return false unless node.is_a?(Node)
    return false unless self.op == n.op
    return self.child == node.child
end

#each {|@child| ... } ⇒ Object

Iterates over the children.

Yields:



729
730
731
# File 'lib/logic_tools/logictree.rb', line 729

def each # :nodoc:
    yield(@child)
end

#getVariablesRecurseObject

Gets the variables, recursively, without postprocessing.

Returns the variables into sets of arrays with possible doublon


724
725
726
# File 'lib/logic_tools/logictree.rb', line 724

def getVariablesRecurse() # :nodoc:
    return @child.getVariablesRecurse
end

#sizeObject

Gets the number of children.



706
707
708
# File 'lib/logic_tools/logictree.rb', line 706

def size # :nodoc:
    1
end

#to_symObject

Converts to a symbol.



741
742
743
# File 'lib/logic_tools/logictree.rb', line 741

def to_sym # :nodoc:
    return @sym
end