Class: LogicTools::VarImp

Inherits:
Variable show all
Defined in:
lib/logic_tools/logicsimplify.rb

Overview

Describes a pseudo variable associated to an implicant.

Used for the Petrick's method

Constant Summary collapse

@@base =

The index of the VarImp for building the variable names

0

Instance Attribute Summary collapse

Attributes inherited from Variable

#value

Instance Method Summary collapse

Methods inherited from Variable

#<=>, exists?, get, #inspect, #to_s

Constructor Details

#initialize(implicant) ⇒ VarImp

Creates a pseudo variable assoctiated to an implicant.



223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/logic_tools/logicsimplify.rb', line 223

def initialize(implicant)
    # Create the name of the variable
    name = nil
    begin
        name = "P" + @@base.to_s
        @@base += 1
    end while Variable.exists?(name)
    # Create the variable
    super(name)
    # Associate it with the implicant
    @implicant = implicant
    implicant.var = self
end

Instance Attribute Details

#implicantObject (readonly)

The implicant the pseudo variable is associated to.



220
221
222
# File 'lib/logic_tools/logicsimplify.rb', line 220

def implicant
  @implicant
end