Sha256: b8c93777cf63a7ecfa2056378464d54a0254791044e5d9a57aaed589883e7d44

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

require 'hashmake'

module SPNet
class ValueInPort < InPort
  
  include Hashmake::HashMakeable

  ARG_SPECS = [
    Hashmake::ArgSpec.new(:key => :get_value_handler, :reqd => true, :type => Proc),
    Hashmake::ArgSpec.new(:key => :set_value_handler, :reqd => true, :type => Proc)
  ]

  def initialize hashed_args = {}
    hash_make(ValueInPort::ARG_SPECS, hashed_args)
    hashed_args.merge!(:matching_port_class => ValueOutPort)
    super(hashed_args)
  end
  
  def set_value value
    @set_value_handler.call value
  end
  
  def get_value
    @get_value_handler.call
  end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spnet-0.1.4 lib/spnet/ports/value_in_port.rb
spnet-0.1.3 lib/spnet/ports/value_in_port.rb