Sha256: 03e2af2445dcbeb5ff29fcdaa30aee934a3f5d3164265cd4ecb317a9cf12c7ae

Contents?: true

Size: 919 Bytes

Versions: 3

Compression:

Stored size: 919 Bytes

Contents

module SPNet

# A port that is used to exercise some functionality exposed by an InPort.
#
# @author James Tunnell
class OutPort
  include Hashmake::HashMakeable
  
  # Define ArgSpec's to use in processing hashed arguments during #initialize.
  ARG_SPECS = {
    :matching_class => arg_spec(:reqd => true, :type => Class),
  }

  attr_reader :name, :link, :matching_class

  # A new instance of OutPort.
  # @param [Hash] args Hashed arguments for initialization. See OutPort::ARG_SPECS
  #                    for details.  
  def initialize args
    hash_make OutPort::ARG_SPECS, args
    @link = nil
  end

  # Set @link to the given Link object.
  def set_link link
    raise ArgumentError, "link 'from' port is not self" unless link.from == self
    @link = link
  end

  # Set @link to nil.
  def clear_link
    @link = nil
  end
  
  # Return true if @link is not nil.
  def linked?
    !link.nil?
  end
end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spnet-0.1.7 lib/spnet/core/out_port.rb
spnet-0.1.6 lib/spnet/core/out_port.rb
spnet-0.1.5 lib/spnet/core/out_port.rb