Class: LogicTools::NodeUnary
Overview
Represents an unary node.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
Instance Method Summary collapse
-
#==(node) ⇒ Object
Compares with
node. -
#each {|@child| ... } ⇒ Object
Iterates over the children.
-
#getVariablesRecurse ⇒ Object
Gets the variables, recursively, without postprocessing.
-
#initialize(op, child) ⇒ NodeUnary
constructor
Creates a node with operator
opand achild. -
#size ⇒ Object
Gets the number of children.
-
#to_sym ⇒ Object
Converts to a symbol.
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
#child ⇒ Object (readonly)
Returns the value of attribute child.
693 694 695 |
# File 'lib/logic_tools/logictree.rb', line 693 def child @child end |
#op ⇒ Object (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.
729 730 731 |
# File 'lib/logic_tools/logictree.rb', line 729 def each # :nodoc: yield(@child) end |
#getVariablesRecurse ⇒ Object
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 |
#size ⇒ Object
Gets the number of children.
706 707 708 |
# File 'lib/logic_tools/logictree.rb', line 706 def size # :nodoc: 1 end |
#to_sym ⇒ Object
Converts to a symbol.
741 742 743 |
# File 'lib/logic_tools/logictree.rb', line 741 def to_sym # :nodoc: return @sym end |