Class: Flowckerc::SolverClass::FormulaExecContext

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(syms, molecule, molecule_ports, options) ⇒ FormulaExecContext

Returns a new instance of FormulaExecContext.



164
165
166
167
168
169
# File 'lib/flowckerc.rb', line 164

def initialize syms, molecule, molecule_ports, options
  @syms = syms
  @molecule = molecule
  @molecule_ports = molecule_ports
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



163
164
165
# File 'lib/flowckerc.rb', line 163

def options
  @options
end

#symsObject (readonly)

Returns the value of attribute syms.



162
163
164
# File 'lib/flowckerc.rb', line 162

def syms
  @syms
end

Instance Method Details

#atom(element, &blk) ⇒ Object



171
172
173
174
175
# File 'lib/flowckerc.rb', line 171

def atom element, &blk
  atom = Atom.new element
  @molecule.atoms.push atom
  AtomExecContext.new(atom, self).instance_exec &blk
end

#inport(name, to_atom, to_port) ⇒ Object



181
182
183
184
185
# File 'lib/flowckerc.rb', line 181

def inport name, to_atom, to_port
  @molecule_ports.inports.push  name: name,
                                to_atom: to_atom,
                                to_port: to_port
end


177
178
179
# File 'lib/flowckerc.rb', line 177

def link spec={}
  @molecule.links.push Link.new spec[:from][0], spec[:from][1], spec[:to][0], spec[:to][1]
end

#mix(formula_file, name, options = {}) ⇒ Object



193
194
195
196
197
198
199
200
# File 'lib/flowckerc.rb', line 193

def mix formula_file, name, options={}
  formula = Formula.new formula_file
  solution = Solver.solve formula, options
  @molecule.atoms += solution.molecule.atoms
  @molecule.links += solution.molecule.links

  @syms.add name, solution
end

#outport(name, from_atom, from_port) ⇒ Object



187
188
189
190
191
# File 'lib/flowckerc.rb', line 187

def outport name, from_atom, from_port
  @molecule_ports.outports.push   name: name,
                                  from_atom: from_atom,
                                  from_port: from_port
end