class Flowckerc::SolverClass

Public Instance Methods

solve(formula, options={}) click to toggle source
# File lib/flowckerc.rb, line 56
def solve formula, options={}
  syms = SymTable.new
  molecule = Molecule.new
  molecule_ports = MoleculePorts.new

  context = FormulaExecContext.new syms, molecule, molecule_ports, options
  formula.eval context

  LinksSolver.new(syms).solve(molecule.links)

  solve_ports_ids syms, molecule_ports

  FormulaSolution.new molecule, molecule_ports
end

Private Instance Methods

solve_ports_ids(syms, molecule_ports) click to toggle source
# File lib/flowckerc.rb, line 73
def solve_ports_ids syms, molecule_ports
  molecule_ports.inports.each do |inport|
    if inport[:to_atom].is_a? Symbol
      inport[:to_atom] = syms.getId inport[:to_atom]
    end
  end

  molecule_ports.outports.each do |outport|
    if outport[:from_atom].is_a? Symbol
      outport[:from_atom] = syms.getId outport[:from_atom]
    end
  end
end