Class: LogicTools::NodeValue

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

Overview

Represents a value node.

Direct Known Subclasses

NodeFalse, NodeTrue

Instance Method Summary collapse

Methods inherited from Node

#cover?, #distribute, #each, #each_line, #each_maxterm, #each_minterm, #eql?, #flatten, #flatten_deep, #get_variables, #hash, #include?, #inspect, #is_parent?, #reduce, #simplify, #size, #to_cover, #to_std_conjunctive, #to_std_disjunctive, #to_sum_product

Instance Method Details

#==(node) ⇒ Object

Compares with node.



318
319
320
321
# File 'lib/logic_tools/logictree.rb', line 318

def ==(node) # :nodoc:
    return false unless node.is_a?(NodeValue)
    return self.eval() == node.eval()
end

#evalObject

Computes the value of the node.



330
331
332
# File 'lib/logic_tools/logictree.rb', line 330

def eval
    return @value
end

#get_variablesRecurseObject

Gets the variables, recursively, without postprocessing.

Returns the variables into sets of arrays with possible doublon


313
314
315
# File 'lib/logic_tools/logictree.rb', line 313

def get_variablesRecurse() # :nodoc:
    return [ ]
end

#opObject

Gets the operator.



335
336
337
# File 'lib/logic_tools/logictree.rb', line 335

def op
    return @value.to_s.to_sym
end

#to_sObject

Converts to a string.



346
347
348
# File 'lib/logic_tools/logictree.rb', line 346

def to_s # :nodoc:
    return @value ? "1" : "0"
end

#to_symObject

Converts to a symbol.



340
341
342
343
# File 'lib/logic_tools/logictree.rb', line 340

def to_sym # :nodoc:
    @sym = @value.to_s.to_sym unless @sym
    return @sym
end