Class: Propose::TruthTable

Inherits:
Object
  • Object
show all
Defined in:
lib/propose/truth_table.rb

Overview

Generates a truth table for a given propositional logic formula.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formula) ⇒ TruthTable

Returns a new instance of TruthTable.



6
7
8
9
# File 'lib/propose/truth_table.rb', line 6

def initialize(formula)
  @formula = formula
  @evaluations = generate(formula)
end

Instance Attribute Details

#evaluationsObject (readonly)

Returns the value of attribute evaluations.



4
5
6
# File 'lib/propose/truth_table.rb', line 4

def evaluations
  @evaluations
end

#formulaObject (readonly)

Returns the value of attribute formula.



4
5
6
# File 'lib/propose/truth_table.rb', line 4

def formula
  @formula
end

Instance Method Details

#formula_atomsObject



11
12
13
# File 'lib/propose/truth_table.rb', line 11

def formula_atoms
  @formula_atoms ||= AtomFinder.new(formula).atoms
end