Class: Flowckerc::SolverClass::FormulaExecContext
- Inherits:
-
Object
- Object
- Flowckerc::SolverClass::FormulaExecContext
- Defined in:
- lib/flowckerc.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#syms ⇒ Object
readonly
Returns the value of attribute syms.
Instance Method Summary collapse
- #atom(element, &blk) ⇒ Object
-
#initialize(syms, molecule, molecule_ports, options) ⇒ FormulaExecContext
constructor
A new instance of FormulaExecContext.
- #inport(name, to_atom, to_port) ⇒ Object
- #link(spec = {}) ⇒ Object
- #mix(formula_file, name, options = {}) ⇒ Object
- #outport(name, from_atom, from_port) ⇒ Object
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, @syms = syms @molecule = molecule @molecule_ports = molecule_ports @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
163 164 165 |
# File 'lib/flowckerc.rb', line 163 def @options end |
#syms ⇒ Object (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 |
#link(spec = {}) ⇒ Object
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, ={} formula = Formula.new formula_file solution = Solver.solve formula, @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 |