Sha256: ea145e61bad19ff095acce9f31fa6441434f2be01435aad068bb6b5d5c9732a3
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
require 'rspec' require 'spnet' include SPNet class TestBlock < Block attr_reader :value1, :value2 def initialize args raise ArgumentError, "args does not have :sample_rate key" unless args.has_key?(:sample_rate) @value1 = 1 @value2 = 2 @command_history = [] input = SignalInPort.new output = SignalOutPort.new value1 = ParamInPort.new( :get_value_handler => ->(){ @value1 }, :set_value_handler => ->(a){ @value1 = a}, ) value2 = ParamInPort.new( :get_value_handler => ->(){ @value2 }, :set_value_handler => ->(a){ @value2 = a}, ) command = CommandInPort.new( :command_map => { "SIT" => ->(a){ @command_history.push("SIT") }, "STAY" => ->(a){ @command_history.push("STAY") } } ) pass_through = lambda do |count| output.enqueue_values input.dequeue_values(count) end super( :sample_rate => args[:sample_rate], :algorithm => pass_through, :in_ports => { "IN" => input, "VALUE1" => value1, "VALUE2" => value2, "COMMAND" => command }, :out_ports => { "OUT" => output } ) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spnet-0.1.8 | spec/spec_helper.rb |
spnet-0.1.7 | spec/spec_helper.rb |