lib/spnet/core/block.rb in spnet-0.1.6 vs lib/spnet/core/block.rb in spnet-0.1.7

- old
+ new

@@ -31,11 +31,11 @@ @algorithm.call count end # Produces a BlockState object based on this Block object. # @return [BlockState] - def export_state + def save_state params = collect_params # discard the params that are the same as the initial port params params.keys.each do |key| if params[key] == @initial_params[key] @@ -44,9 +44,17 @@ end BlockState.new(:class_sym => self.class.to_s.to_sym, :params => params) end + def restore_state state + state.params.each do |port_name,value| + if @in_ports.has_key?(port_name) + @in_ports[port_name].set_value value + end + end + end + private def collect_params params = {}