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?, #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.
846 847 848 849 850 851 852 853 854 |
# File 'lib/logic_tools/logictree.rb', line 846 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.
843 844 845 |
# File 'lib/logic_tools/logictree.rb', line 843 def child @child end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
843 844 845 |
# File 'lib/logic_tools/logictree.rb', line 843 def op @op end |
Instance Method Details
#==(node) ⇒ Object
Compares with node.
894 895 896 897 898 |
# File 'lib/logic_tools/logictree.rb', line 894 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.
885 886 887 888 889 890 891 |
# File 'lib/logic_tools/logictree.rb', line 885 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
880 881 882 |
# File 'lib/logic_tools/logictree.rb', line 880 def get_variablesRecurse() # :nodoc: return @child.get_variablesRecurse end |
#include?(tree) ⇒ Boolean
Tells if the self includes tree.
901 902 903 904 905 906 907 |
# File 'lib/logic_tools/logictree.rb', line 901 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.
857 858 859 |
# File 'lib/logic_tools/logictree.rb', line 857 def is_parent? return true end |
#size ⇒ Object
Gets the number of children.
862 863 864 |
# File 'lib/logic_tools/logictree.rb', line 862 def size # :nodoc: 1 end |
#to_sym ⇒ Object
Converts to a symbol.
910 911 912 913 |
# File 'lib/logic_tools/logictree.rb', line 910 def to_sym # :nodoc: @sym = self.to_s.to_sym unless @sym return @sym end |