Class: Flowckerc::SolverClass::LinksSolver

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

Instance Method Summary collapse

Constructor Details

#initialize(syms) ⇒ LinksSolver

Returns a new instance of LinksSolver.



88
89
90
# File 'lib/flowckerc.rb', line 88

def initialize syms
  @syms = syms
end

Instance Method Details

#solve(links) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/flowckerc.rb', line 92

def solve links
  links.each do |link|
    if link.from_atom.is_a? Symbol
      solve_src link
    end
    if link.to_atom.is_a? Symbol
      solve_dst link
    end
  end
end

#solve_dst(link) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/flowckerc.rb', line 116

def solve_dst link
  name = link.to_atom
  port = link.to_port
  if @syms.isAtom name
    link.to_atom = @syms.getId name
  else
    solution = @syms.value name
    actual_port =  solution.molecule_ports.inportByName port
    link.to_atom = actual_port[:to_atom]
    link.to_port = actual_port[:to_port]
  end
end

#solve_src(link) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/flowckerc.rb', line 103

def solve_src link
  name = link.from_atom
  port = link.from_port
  if @syms.isAtom name
    link.from_atom = @syms.getId name
  else
    solution = @syms.value name
    actual_port =  solution.molecule_ports.outportByName port
    link.from_atom = actual_port[:from_atom]
    link.from_port = actual_port[:from_port]
  end
end