Sha256: 4d455f10a678f049364efef934a154f6e410bfcf466c8ca4462e39883a3baedb

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

module SPNet

# A port that exposes some functionality in a block.
#
# @author James Tunnell
class InPort
  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 :link, :matching_class
  
  # A new instance of InPort.
  # @param [Hash] args Hashed arguments for initialization. See InPort::ARG_SPECS
  #                    for details.
  def initialize args
    hash_make args, InPort::ARG_SPECS
    @link = nil
  end

  # Set @link to the given Link object.
  def set_link link
    raise ArgumentError, "link 'to' port is not self" unless link.to == 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

1 entries across 1 versions & 1 rubygems

Version Path
spnet-0.1.8 lib/spnet/core/in_port.rb