Sha256: 23fd95904a26ca42aac80345c92e14569923cd535341cd0a9f0c0c9d19f35c1f

Contents?: true

Size: 645 Bytes

Versions: 2

Compression:

Stored size: 645 Bytes

Contents

module Logicle
  class Simulator
    attr_reader  :circuit

    def initialize(*circuits)
      @circuit = load(circuits.shift)
      unless circuits.empty?
        @sub_circuits = circuits.map { |circuit_file| load(circuit_file) }
      end
    end

    def inputs
      @circuit.inputs.values
    end

    def outputs
      @circuit.outputs.values
    end

    def evaluate
      @circuit.evaluate
    end

    def save(output_file)
      writer = TgfWriter.new(output_file, @circuit)
      writer.write
    end

    private
    def load(circuit_file)
      reader = TgfReader.new(circuit_file)
      @circuit = reader.parse
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logicle-0.1.1 lib/logicle/simulator.rb
logicle-0.1.0 lib/logicle/simulator.rb