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.
-
#get_variablesRecurse ⇒ Object
Gets the variables, recursively, without postprocessing.
-
#include?(tree) ⇒ Boolean
Tells if the
selfincludestree. -
#initialize(op, child) ⇒ NodeUnary
constructor
Creates a node with operator
opand achild. -
#is_parent? ⇒ Boolean
Tells if the node is a parent.
-
#size ⇒ Object
Gets the number of children.
-
#to_sym ⇒ Object
Converts to a symbol.
Methods inherited from Node
#cover?, #distribute, #each_line, #each_maxterm, #each_minterm, #eql?, #eval_input, #flatten, #flatten_deep, #get_variables, #hash, #inspect, #reduce, #simplify, #to_cover, #to_std_conjunctive, #to_std_disjunctive, #to_sum_product
Constructor Details
#initialize(op, child) ⇒ NodeUnary
Creates a node with operator op and a child.
874 875 876 877 878 879 880 881 882 |
# File 'lib/logic_tools/logictree.rb', line 874 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 @sym = nil end |
Instance Attribute Details
#child ⇒ Object (readonly)
Returns the value of attribute child.
871 872 873 |
# File 'lib/logic_tools/logictree.rb', line 871 def child @child end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
871 872 873 |
# File 'lib/logic_tools/logictree.rb', line 871 def op @op end |
Instance Method Details
#==(node) ⇒ Object
Compares with node.
922 923 924 925 926 |
# File 'lib/logic_tools/logictree.rb', line 922 def ==(node) # :nodoc: return false unless node.is_a?(Node) return false unless self.op == node.op return self.child == node.child end |
#each {|@child| ... } ⇒ Object
Iterates over the children.
913 914 915 916 917 918 919 |
# File 'lib/logic_tools/logictree.rb', line 913 def each # :nodoc: # No block given? Return an enumerator. return to_enum(:each) unless block_given? # Block given? Apply it. yield(@child) end |
#get_variablesRecurse ⇒ Object
Gets the variables, recursively, without postprocessing.
Returns the variables into sets of arrays with possible doublon
908 909 910 |
# File 'lib/logic_tools/logictree.rb', line 908 def get_variablesRecurse() # :nodoc: return @child.get_variablesRecurse end |
#include?(tree) ⇒ Boolean
Tells if the self includes tree.
929 930 931 932 933 934 935 |
# File 'lib/logic_tools/logictree.rb', line 929 def include?(tree) return true if self == tree # Same tree, so inclusion. # Check the child return true if @child.include?(tree) # Do not include return false end |
#is_parent? ⇒ Boolean
Tells if the node is a parent.
885 886 887 |
# File 'lib/logic_tools/logictree.rb', line 885 def is_parent? return true end |
#size ⇒ Object
Gets the number of children.
890 891 892 |
# File 'lib/logic_tools/logictree.rb', line 890 def size # :nodoc: 1 end |
#to_sym ⇒ Object
Converts to a symbol.
938 939 940 941 |
# File 'lib/logic_tools/logictree.rb', line 938 def to_sym # :nodoc: @sym = self.to_s.to_sym unless @sym return @sym end |